Conditions | 5 |
Paths | 9 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
44 | 9 | public function find(array $conditions): ?ArrayAccess |
|
45 | { |
||
46 | 9 | $table = $this->getTableLocator()->get($this->getConfig('userModel')); |
|
47 | |||
48 | 9 | $query = $table->query(); |
|
49 | 9 | $finders = (array)$this->getConfig('finder'); |
|
50 | 9 | foreach ($finders as $finder => $options) { |
|
51 | 9 | if (is_string($options)) { |
|
52 | 9 | $query->find($options); |
|
53 | } else { |
||
54 | 9 | $query->find($finder, $options); |
|
55 | } |
||
56 | } |
||
57 | |||
58 | 9 | $where = []; |
|
59 | 9 | foreach ($conditions as $field => $value) { |
|
60 | 9 | $field = $table->aliasField($field); |
|
61 | 9 | if (is_array($value)) { |
|
62 | 1 | $field = $field . ' IN'; |
|
63 | } |
||
64 | 9 | $where[$field] = $value; |
|
65 | } |
||
66 | |||
67 | 9 | return $query->where($where)->first(); |
|
|
|||
68 | } |
||
70 |