1 | <?php |
||
13 | class CodeigniterModel extends \CI_Model |
||
14 | { |
||
15 | /** |
||
16 | * @var \Rougin\Credo\Credo |
||
17 | */ |
||
18 | protected $credo; |
||
19 | |||
20 | /** |
||
21 | * @var \Doctrine\ORM\EntityRepository |
||
22 | */ |
||
23 | protected $repository; |
||
24 | |||
25 | 3 | public function __construct() |
|
32 | |||
33 | /** |
||
34 | * Returns all of the models from the database. |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | 3 | public function all() |
|
42 | |||
43 | /** |
||
44 | * Returns a total rows from the specified table. |
||
45 | * |
||
46 | * @return integer |
||
47 | */ |
||
48 | 3 | public function countAll() |
|
59 | |||
60 | /** |
||
61 | * Deletes the specified ID of the model from the database. |
||
62 | * |
||
63 | * @param integer $id |
||
64 | * @return void |
||
65 | */ |
||
66 | 3 | public function delete($id) |
|
75 | |||
76 | /** |
||
77 | * Finds an entity by its primary key / identifier. |
||
78 | * |
||
79 | * @param mixed $id |
||
80 | * @param int|null $lockMode |
||
81 | * @param int|null $lockVersion |
||
82 | * @return object|null |
||
83 | */ |
||
84 | 12 | public function find($id, $lockMode = null, $lockVersion = null) |
|
88 | |||
89 | /** |
||
90 | * Finds models by a set of criteria. |
||
91 | * |
||
92 | * @param array $criteria |
||
93 | * @param array|null $orderBy |
||
94 | * @param integer|null $limit |
||
95 | * @param integer|null $offset |
||
96 | * @return array |
||
97 | */ |
||
98 | 6 | public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
102 | |||
103 | /** |
||
104 | * Inserts a new row into the table. |
||
105 | * |
||
106 | * @param array $data |
||
107 | * @return integer |
||
108 | */ |
||
109 | 3 | public function insert(array $data) |
|
121 | |||
122 | /** |
||
123 | * Updates the selected row from the table. |
||
124 | * |
||
125 | * @param integer $id |
||
126 | * @param array $data |
||
127 | * @return boolean |
||
128 | */ |
||
129 | 3 | public function update($id, array $data) |
|
142 | |||
143 | /** |
||
144 | * Returns the table name and the corresponding primary key. |
||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | 9 | protected function getTableNameAndPrimaryKey() |
|
155 | } |
||
156 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: