| Total Complexity | 8 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 88.24% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 13 | trait HasPrimaryKeyTrait |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var null|string |
||
| 17 | */ |
||
| 18 | protected $primaryKey = null; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param $params |
||
| 22 | */ |
||
| 23 | 6 | public function checkParamPrimaryKey($params) |
|
| 24 | { |
||
| 25 | 6 | if (isset($params['primaryKey'])) { |
|
| 26 | $this->setPrimaryKey($params['primaryKey']); |
||
| 27 | unset($params['primaryKey']); |
||
| 28 | } |
||
| 29 | 6 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | 6 | public function getPrimaryKey() |
|
| 35 | { |
||
| 36 | 6 | if ($this->primaryKey == null) { |
|
|
|
|||
| 37 | 6 | $this->initPrimaryKey(); |
|
| 38 | } |
||
| 39 | |||
| 40 | 6 | return $this->primaryKey; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param $name |
||
| 45 | */ |
||
| 46 | 6 | public function setPrimaryKey($name) |
|
| 49 | 6 | } |
|
| 50 | |||
| 51 | 6 | protected function initPrimaryKey() |
|
| 54 | 6 | } |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | 6 | protected function generatePrimaryKey() |
|
| 64 |