Skip to content

Commit 41dec56

Browse files
committed
Create assert true shortcut in column class
1 parent 4321b87 commit 41dec56

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/Database/Column.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function defaults($value)
140140
*/
141141
public function exists()
142142
{
143-
$this->context->assertTrue(
143+
$this->assertTrue(
144144
$this->table->hasColumn($this->name), "The table column `{$this->name}` does not exist."
145145
);
146146

@@ -154,11 +154,9 @@ public function exists()
154154
*/
155155
public function increments()
156156
{
157-
$this->integer()->context->assertTrue(
158-
$this->get('autoincrement'), "The column {$this->name} is not auto-incremented."
159-
);
160-
161-
return $this->primary();
157+
return $this->integer()
158+
->assertTrue($this->get('autoincrement'), "The column {$this->name} is not auto-incremented.")
159+
->primary();
162160
}
163161

164162
/**
@@ -272,6 +270,20 @@ protected function assertColumn($method, $args)
272270
throw new \Exception("The database table column assertion {$method} does not exist.");
273271
}
274272

273+
/**
274+
* Assert a condition is true alias.
275+
*
276+
* @param bool $condition
277+
* @param string $message
278+
* @return $this
279+
*/
280+
protected function assertTrue($condition, $message)
281+
{
282+
$this->context->assertTrue($condition, $message);
283+
284+
return $this;
285+
}
286+
275287
/**
276288
* Assert a key is a unique index.
277289
*

0 commit comments

Comments
 (0)