@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | |
105 | 105 | public function offsetExists($offset) { |
106 | 106 | if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey()); |
107 | - if (!empty($this->settings['filter'])) { |
|
108 | - $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
109 | - return isset($data[0]); |
|
110 | - } |
|
107 | + if (!empty($this->settings['filter'])) { |
|
108 | + $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
109 | + return isset($data[0]); |
|
110 | + } |
|
111 | 111 | return (bool) $this->dataSource->findById($offset); |
112 | 112 | } |
113 | 113 | |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | |
118 | 118 | public function offsetGet($offset) { |
119 | 119 | if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey()); |
120 | - if (!empty($this->settings['filter'])) { |
|
121 | - $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
122 | - return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations); |
|
123 | - } |
|
120 | + if (!empty($this->settings['filter'])) { |
|
121 | + $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
122 | + return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations); |
|
123 | + } |
|
124 | 124 | return $this->entity->create($this->dataSource->findById($offset), $this->relations); |
125 | 125 | } |
126 | 126 |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Maphper; |
3 | 3 | class Maphper implements \Countable, \ArrayAccess, \IteratorAggregate { |
4 | - const FIND_EXACT = 0x1; |
|
5 | - const FIND_LIKE = 0x2; |
|
6 | - const FIND_STARTS = 0x4; |
|
7 | - const FIND_ENDS = 0x8; |
|
8 | - const FIND_BIT = 0x10; |
|
9 | - const FIND_GREATER = 0x20; |
|
10 | - const FIND_LESS = 0x40; |
|
11 | - const FIND_EXPRESSION = 0x80; |
|
12 | - const FIND_AND = 0x100; |
|
13 | - const FIND_OR = 0x200; |
|
14 | - const FIND_NOT = 0x400; |
|
15 | - const FIND_BETWEEN = 0x800; |
|
16 | - const FIND_NOCASE = 0x1000; |
|
4 | + const FIND_EXACT = 0x1; |
|
5 | + const FIND_LIKE = 0x2; |
|
6 | + const FIND_STARTS = 0x4; |
|
7 | + const FIND_ENDS = 0x8; |
|
8 | + const FIND_BIT = 0x10; |
|
9 | + const FIND_GREATER = 0x20; |
|
10 | + const FIND_LESS = 0x40; |
|
11 | + const FIND_EXPRESSION = 0x80; |
|
12 | + const FIND_AND = 0x100; |
|
13 | + const FIND_OR = 0x200; |
|
14 | + const FIND_NOT = 0x400; |
|
15 | + const FIND_BETWEEN = 0x800; |
|
16 | + const FIND_NOCASE = 0x1000; |
|
17 | 17 | |
18 | 18 | private $dataSource; |
19 | 19 | private $relations = []; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | } |
59 | 59 | $results = $this->dataSource->findByField($this->settings['filter'], |
60 | - ['order' => $this->settings['sort'], 'limit' => $this->settings['limit'], 'offset' => $this->settings['offset'] ]); |
|
60 | + ['order' => $this->settings['sort'], 'limit' => $this->settings['limit'], 'offset' => $this->settings['offset']]); |
|
61 | 61 | |
62 | 62 | $siblings = new \ArrayObject(); |
63 | 63 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
109 | 109 | return isset($data[0]); |
110 | 110 | } |
111 | - return (bool) $this->dataSource->findById($offset); |
|
111 | + return (bool)$this->dataSource->findById($offset); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function offsetUnset($id) { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | public function wrap($relations, $object, $siblings = []) { |
22 | 22 | //see if any relations need overwriting |
23 | 23 | foreach ($relations as $name => $relation) { |
24 | - if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) { |
|
24 | + if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation)) { |
|
25 | 25 | //After overwriting the relation, does the parent object ($object) need overwriting as well? |
26 | 26 | if ($relation->overwrite($object, $object->$name)) $this->parent[] = $object; |
27 | 27 | } |