@@ -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 = []; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | $results = $this->dataSource->findByField($this->settings['filter'], |
| 57 | - ['order' => $this->settings['sort'], 'limit' => $this->settings['limit'], 'offset' => $this->settings['offset'] ]); |
|
| 57 | + ['order' => $this->settings['sort'], 'limit' => $this->settings['limit'], 'offset' => $this->settings['offset']]); |
|
| 58 | 58 | |
| 59 | 59 | $siblings = new \ArrayObject(); |
| 60 | 60 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $valueCopy = clone $value; |
| 95 | 95 | $value = $this->wrap($value); |
| 96 | 96 | $this->dataSource->save($value); |
| 97 | - $value = $this->wrap((object) array_merge((array)$value, (array)$valueCopy)); |
|
| 97 | + $value = $this->wrap((object)array_merge((array)$value, (array)$valueCopy)); |
|
| 98 | 98 | $this->createNew($value, $valueObj); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
| 105 | 105 | return isset($data[0]); |
| 106 | 106 | } |
| 107 | - return (bool) $this->dataSource->findById($offset); |
|
| 107 | + return (bool)$this->dataSource->findById($offset); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | public function offsetUnset($id) { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | private function wrap($object, $key = null, $siblings = null) { |
| 140 | 140 | //see if any relations need overwriting |
| 141 | 141 | foreach ($this->relations as $name => $relation) { |
| 142 | - if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) { |
|
| 142 | + if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation)) { |
|
| 143 | 143 | //After overwriting the relation, does the parent object ($object) need overwriting as well? |
| 144 | 144 | if ($relation->overwrite($object, $object->$name)) $this[] = $object; |
| 145 | 145 | } |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | private $closure; |
| 5 | 5 | public function __construct($object) { |
| 6 | 6 | if ($object instanceof \stdclass) { |
| 7 | - $this->closure = function ($field, $value) use ($object) { $object->$field = $value; }; |
|
| 7 | + $this->closure = function($field, $value) use ($object) { $object->$field = $value; }; |
|
| 8 | 8 | } |
| 9 | 9 | else { |
| 10 | - $this->closure = function ($field, $value) { $this->$field = $value; }; |
|
| 10 | + $this->closure = function($field, $value) { $this->$field = $value; }; |
|
| 11 | 11 | $this->closure = $this->closure->bindTo($object, $object); |
| 12 | 12 | } |
| 13 | 13 | } |