|
@@ 108-119 (lines=12) @@
|
| 105 |
|
* |
| 106 |
|
* @return bool Returns boolean true if the instance was successfully deleted or else it returns false. |
| 107 |
|
*/ |
| 108 |
|
public static function destroy($number) |
| 109 |
|
{ |
| 110 |
|
if (! is_int($number)) { |
| 111 |
|
throw new InvalidArgumentException("The parameter {$number} is not an integer. An integer is required instead."); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
if ($number <= 0) { |
| 115 |
|
throw new InvalidArgumentException("The parameter {$number} is not a positive integer. A positive integer is required instead."); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
return self::$_connection->deleteRecord(self::$_table, $number - 1); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
/** |
| 122 |
|
* Finds a specified instance of the model in the database. |
|
@@ 128-141 (lines=14) @@
|
| 125 |
|
* |
| 126 |
|
* @return array Returns the particular instance of the model. |
| 127 |
|
*/ |
| 128 |
|
public static function find($number) |
| 129 |
|
{ |
| 130 |
|
if (! is_int($number)) { |
| 131 |
|
throw new InvalidArgumentException("The parameter {$number} is not an integer. An integer is required instead."); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
if ($number <= 0) { |
| 135 |
|
throw new InvalidArgumentException("The parameter {$number} is not a positive integer. A positive integer is required instead."); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
$record = self::$_connection->findRecord(self::$_table, $number - 1); |
| 139 |
|
|
| 140 |
|
return new self($record); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
/** |
| 144 |
|
* Returns all instances of the model in the database. |