@@ -74,7 +74,7 @@ |
||
74 | 74 | |
75 | 75 | public function __get($name) { |
76 | 76 | if ($this->lazyLoad()) return $this->lazyLoad()->$name; |
77 | - else return null; |
|
77 | + else return null; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function __isset($name) { |
@@ -7,17 +7,17 @@ |
||
7 | 7 | private $intermediateName; |
8 | 8 | |
9 | 9 | public function __construct(\Maphper\Iterator $iterator, $intermediateName = null) { |
10 | - $this->iterator = $iterator; |
|
11 | - $this->intermediateName = $intermediateName; |
|
10 | + $this->iterator = $iterator; |
|
11 | + $this->intermediateName = $intermediateName; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function current() { |
15 | - if ($this->intermediateName) return $this->iterator->current()->{$this->intermediateName}; |
|
15 | + if ($this->intermediateName) return $this->iterator->current()->{$this->intermediateName}; |
|
16 | 16 | return $this->iterator->current(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | public function key() { |
20 | - return $this->iterator->key(); |
|
20 | + return $this->iterator->key(); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function next() { |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function query(\Maphper\Lib\Query $query) { |
28 | 28 | $stmt = $this->getCachedStmt($query->getSql()); |
29 | 29 | $args = $query->getArgs(); |
30 | - $stmt->execute($args); |
|
30 | + $stmt->execute($args); |
|
31 | 31 | |
32 | 32 | if (strpos(trim($query->getSql()), 'SELECT') === 0) return $stmt->fetchAll(\PDO::FETCH_OBJ); |
33 | 33 | else return $stmt; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | return '`' . str_replace('.', '`.`', trim($str, '`')) . '`'; |
14 | 14 | } |
15 | 15 | |
16 | - private function getCachedStmt($sql) { |
|
16 | + private function getCachedStmt($sql) { |
|
17 | 17 | $queryId = md5($sql); |
18 | 18 | if (isset($this->queryCache[$queryId])) $stmt = $this->queryCache[$queryId]; |
19 | 19 | else { |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | |
26 | 26 | public function query(\Maphper\Lib\Query $query) { |
27 | 27 | $queryId = md5($query->getSql()); |
28 | - $stmt = $this->getCachedStmt($query->getSql()); |
|
28 | + $stmt = $this->getCachedStmt($query->getSql()); |
|
29 | 29 | $args = $query->getArgs(); |
30 | 30 | |
31 | - //Handle SQLite when PDO_ERRMODE is set to SILENT |
|
32 | - if ($stmt === false) throw new \Exception('Invalid query'); |
|
31 | + //Handle SQLite when PDO_ERRMODE is set to SILENT |
|
32 | + if ($stmt === false) throw new \Exception('Invalid query'); |
|
33 | 33 | |
34 | - $stmt->execute($args); |
|
35 | - if ($stmt->errorCode() !== '00000' && $stmt->errorInfo()[2] == 'database schema has changed') { |
|
34 | + $stmt->execute($args); |
|
35 | + if ($stmt->errorCode() !== '00000' && $stmt->errorInfo()[2] == 'database schema has changed') { |
|
36 | 36 | unset($this->queryCache[$queryId]); |
37 | 37 | return $this->query($query); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - if (substr($query->getSql(), 0, 6) === 'SELECT') return $stmt->fetchAll(\PDO::FETCH_OBJ); |
|
41 | - else return $stmt; |
|
40 | + if (substr($query->getSql(), 0, 6) === 'SELECT') return $stmt->fetchAll(\PDO::FETCH_OBJ); |
|
41 | + else return $stmt; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function lastInsertId() { |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | $sql = []; |
31 | 31 | |
32 | 32 | foreach ($fields as $key => $value) { |
33 | - if ($value instanceof \DateTime) { |
|
34 | - if ($value->format('H:i:s') == '00:00:00') $value = $value->format('Y-m-d'); |
|
35 | - else $value = $value->format('Y-m-d H:i:s'); |
|
36 | - } |
|
33 | + if ($value instanceof \DateTime) { |
|
34 | + if ($value->format('H:i:s') == '00:00:00') $value = $value->format('Y-m-d'); |
|
35 | + else $value = $value->format('Y-m-d H:i:s'); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | if (is_numeric($key) && is_array($value)) { |
39 | 39 | $result = $this->createSql($value, $key); |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | return ['args' => $args, 'sql' => [$query]]; |
86 | 86 | } |
87 | 87 | |
88 | - private function getOperator($mode) { |
|
89 | - $operator = ""; |
|
88 | + private function getOperator($mode) { |
|
89 | + $operator = ""; |
|
90 | 90 | |
91 | - if (\Maphper\Maphper::FIND_NOCASE & $mode) $operator = 'LIKE'; |
|
92 | - else if (\Maphper\Maphper::FIND_BIT & $mode) $operator = '&'; |
|
93 | - else if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>'; |
|
94 | - else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<'; |
|
95 | - else if (\Maphper\Maphper::FIND_NOT & $mode) $operator = '!='; |
|
91 | + if (\Maphper\Maphper::FIND_NOCASE & $mode) $operator = 'LIKE'; |
|
92 | + else if (\Maphper\Maphper::FIND_BIT & $mode) $operator = '&'; |
|
93 | + else if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>'; |
|
94 | + else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<'; |
|
95 | + else if (\Maphper\Maphper::FIND_NOT & $mode) $operator = '!='; |
|
96 | 96 | |
97 | - if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '='; |
|
97 | + if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '='; |
|
98 | 98 | |
99 | - return $operator; |
|
100 | - } |
|
99 | + return $operator; |
|
100 | + } |
|
101 | 101 | } |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | $value = $this->entity->wrap($this->relations, $value); |
97 | 97 | $this->dataSource->save($value); |
98 | 98 | $visibilityOverride->write($value); |
99 | - $this->entity->create((array_merge((array)$value, (array)$valueCopy)), $this->relations); |
|
99 | + $this->entity->create((array_merge((array)$value, (array)$valueCopy)), $this->relations); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey()); |
104 | - if (!empty($this->settings['filter'])) { |
|
105 | - $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
106 | - return isset($data[0]); |
|
107 | - } |
|
104 | + if (!empty($this->settings['filter'])) { |
|
105 | + $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
106 | + return isset($data[0]); |
|
107 | + } |
|
108 | 108 | return (bool) $this->dataSource->findById($offset); |
109 | 109 | } |
110 | 110 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | |
115 | 115 | public function offsetGet($offset) { |
116 | 116 | if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey()); |
117 | - if (!empty($this->settings['filter'])) { |
|
118 | - $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
119 | - return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations); |
|
120 | - } |
|
117 | + if (!empty($this->settings['filter'])) { |
|
118 | + $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset])); |
|
119 | + return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations); |
|
120 | + } |
|
121 | 121 | return $this->entity->create($this->dataSource->findById($offset), $this->relations); |
122 | 122 | } |
123 | 123 |
@@ -4,7 +4,7 @@ |
||
4 | 4 | private $parent; |
5 | 5 | private $primaryKey; |
6 | 6 | private $lookup; |
7 | - private $mapper; |
|
7 | + private $mapper; |
|
8 | 8 | |
9 | 9 | public function __construct(Maphper $mapper, $lookup, array $primaryKey, MultiPk $parent = null) { |
10 | 10 | $this->parent = $parent; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | const EDIT_OPTIMISE = 4; |
7 | 7 | |
8 | 8 | private $table; |
9 | - private $options; |
|
9 | + private $options; |
|
10 | 10 | private $cache = []; |
11 | 11 | private $primaryKey; |
12 | 12 | private $fields = '*'; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | private $alterDb = false; |
16 | 16 | private $adapter; |
17 | 17 | private $crudBuilder; |
18 | - private $selecctBuilder; |
|
18 | + private $selecctBuilder; |
|
19 | 19 | |
20 | 20 | public function __construct($db, $table, $primaryKey = 'id', array $options = []) { |
21 | 21 | $this->options = new DatabaseOptions($db, $options); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | else $limit = ''; |
117 | 117 | |
118 | 118 | $query = $this->selectBuilder->createSql($fields, $mode); |
119 | - $query['sql'] = array_filter($query['sql']); |
|
119 | + $query['sql'] = array_filter($query['sql']); |
|
120 | 120 | $this->adapter->query($this->crudBuilder->delete($this->table, $query['sql'], $query['args'], $limit)); |
121 | 121 | $this->addIndex(array_keys($query['args'])); |
122 | 122 | |
@@ -125,23 +125,23 @@ discard block |
||
125 | 125 | $this->resultCache = []; |
126 | 126 | } |
127 | 127 | |
128 | - private function getIfNew($data) { |
|
129 | - $new = false; |
|
130 | - foreach ($this->primaryKey as $k) { |
|
131 | - if (empty($data->$k)) { |
|
132 | - $data->$k = null; |
|
133 | - $new = true; |
|
134 | - } |
|
135 | - } |
|
136 | - return $new; |
|
137 | - } |
|
128 | + private function getIfNew($data) { |
|
129 | + $new = false; |
|
130 | + foreach ($this->primaryKey as $k) { |
|
131 | + if (empty($data->$k)) { |
|
132 | + $data->$k = null; |
|
133 | + $new = true; |
|
134 | + } |
|
135 | + } |
|
136 | + return $new; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | public function save($data, $tryagain = true) { |
140 | 140 | $tryagain = $tryagain && self::EDIT_STRUCTURE & $this->alterDb; |
141 | - $new = $this->getIfNew($data); |
|
141 | + $new = $this->getIfNew($data); |
|
142 | 142 | |
143 | 143 | try { |
144 | - $result = $this->insert($this->table, $this->primaryKey, $data); |
|
144 | + $result = $this->insert($this->table, $this->primaryKey, $data); |
|
145 | 145 | |
146 | 146 | //If there was an error but PDO is silent, trigger the catch block anyway |
147 | 147 | if ($result->errorCode() !== '00000') throw new \Exception('Could not insert into ' . $this->table); |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | $this->updateCache($data); |
160 | 160 | } |
161 | 161 | |
162 | - private function updatePK($data, $new) { |
|
163 | - if ($new && count($this->primaryKey) == 1) $data->{$this->primaryKey[0]} = $this->adapter->lastInsertId(); |
|
164 | - } |
|
162 | + private function updatePK($data, $new) { |
|
163 | + if ($new && count($this->primaryKey) == 1) $data->{$this->primaryKey[0]} = $this->adapter->lastInsertId(); |
|
164 | + } |
|
165 | 165 | |
166 | - private function checkIfUpdateWorked($data) { |
|
167 | - $updateWhere = $this->crudBuilder->update($this->table, $this->primaryKey, $data); |
|
168 | - $matched = $this->findByField($updateWhere->getArgs()); |
|
166 | + private function checkIfUpdateWorked($data) { |
|
167 | + $updateWhere = $this->crudBuilder->update($this->table, $this->primaryKey, $data); |
|
168 | + $matched = $this->findByField($updateWhere->getArgs()); |
|
169 | 169 | |
170 | - if (count($matched) == 0) throw new \InvalidArgumentException('Record inserted into table ' . $this->table . ' fails table constraints'); |
|
171 | - } |
|
170 | + if (count($matched) == 0) throw new \InvalidArgumentException('Record inserted into table ' . $this->table . ' fails table constraints'); |
|
171 | + } |
|
172 | 172 | |
173 | - private function updateCache($data) { |
|
174 | - $pkValue = $data->{$this->primaryKey[0]}; |
|
173 | + private function updateCache($data) { |
|
174 | + $pkValue = $data->{$this->primaryKey[0]}; |
|
175 | 175 | if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data); |
176 | 176 | else $this->cache[$pkValue] = $data; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | private function insert($table, array $primaryKey, $data) { |
180 | 180 | $error = 0; |
@@ -186,16 +186,16 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | if ($error || $result->errorCode() !== '00000') { |
189 | - $result = $this->tryUpdate($table, $primaryKey, $data); |
|
190 | - } |
|
189 | + $result = $this->tryUpdate($table, $primaryKey, $data); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | return $result; |
193 | 193 | } |
194 | 194 | |
195 | - private function tryUpdate($table, array $primaryKey, $data) { |
|
196 | - $result = $this->adapter->query($this->crudBuilder->update($table, $primaryKey, $data)); |
|
197 | - if ($result->rowCount() === 0) $this->checkIfUpdateWorked($data); |
|
195 | + private function tryUpdate($table, array $primaryKey, $data) { |
|
196 | + $result = $this->adapter->query($this->crudBuilder->update($table, $primaryKey, $data)); |
|
197 | + if ($result->rowCount() === 0) $this->checkIfUpdateWorked($data); |
|
198 | 198 | |
199 | - return $result; |
|
200 | - } |
|
199 | + return $result; |
|
200 | + } |
|
201 | 201 | } |
@@ -2,112 +2,112 @@ |
||
2 | 2 | namespace Maphper\DataSource; |
3 | 3 | use Maphper\Maphper; |
4 | 4 | class Mock implements \Maphper\DataSource { |
5 | - private $data; |
|
6 | - private $id; |
|
5 | + private $data; |
|
6 | + private $id; |
|
7 | 7 | |
8 | - public function __construct(\ArrayObject $data, $id) { |
|
9 | - $this->data = $data; |
|
10 | - $this->id = is_array($id) ? $id : [$id]; |
|
11 | - } |
|
8 | + public function __construct(\ArrayObject $data, $id) { |
|
9 | + $this->data = $data; |
|
10 | + $this->id = is_array($id) ? $id : [$id]; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getPrimaryKey() { |
|
14 | - return $this->id; |
|
15 | - } |
|
13 | + public function getPrimaryKey() { |
|
14 | + return $this->id; |
|
15 | + } |
|
16 | 16 | |
17 | - public function findById($id) { |
|
18 | - return isset($this->data[$id]) ? (array)$this->data[$id] : []; |
|
19 | - } |
|
17 | + public function findById($id) { |
|
18 | + return isset($this->data[$id]) ? (array)$this->data[$id] : []; |
|
19 | + } |
|
20 | 20 | |
21 | - public function findByField(array $fields, $options = []) { |
|
22 | - $array = iterator_to_array($this->data->getIterator()); |
|
23 | - $filteredArray = array_filter($array, $this->getSearchFieldFunction($fields, \Maphper\Maphper::FIND_EXACT | \Maphper\Maphper::FIND_AND)); |
|
24 | - // Need to reset indexes |
|
25 | - $filteredArray = array_values($filteredArray); |
|
26 | - if (isset($options['order'])) { |
|
27 | - list($columns, $order) = explode(' ', $options['order']); |
|
28 | - usort($filteredArray, $this->getOrderFunction($order, $columns)); |
|
29 | - } |
|
30 | - if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']); |
|
31 | - if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']); |
|
32 | - return $filteredArray; |
|
33 | - } |
|
21 | + public function findByField(array $fields, $options = []) { |
|
22 | + $array = iterator_to_array($this->data->getIterator()); |
|
23 | + $filteredArray = array_filter($array, $this->getSearchFieldFunction($fields, \Maphper\Maphper::FIND_EXACT | \Maphper\Maphper::FIND_AND)); |
|
24 | + // Need to reset indexes |
|
25 | + $filteredArray = array_values($filteredArray); |
|
26 | + if (isset($options['order'])) { |
|
27 | + list($columns, $order) = explode(' ', $options['order']); |
|
28 | + usort($filteredArray, $this->getOrderFunction($order, $columns)); |
|
29 | + } |
|
30 | + if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']); |
|
31 | + if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']); |
|
32 | + return $filteredArray; |
|
33 | + } |
|
34 | 34 | |
35 | - private function getSearchFieldFunction($fields, $mode) { |
|
36 | - return function ($data) use ($fields, $mode) { |
|
37 | - foreach ($fields as $key => $val) { |
|
38 | - $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode); |
|
35 | + private function getSearchFieldFunction($fields, $mode) { |
|
36 | + return function ($data) use ($fields, $mode) { |
|
37 | + foreach ($fields as $key => $val) { |
|
38 | + $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode); |
|
39 | 39 | |
40 | - if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true; |
|
41 | - else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false; |
|
42 | - } |
|
43 | - return !(Maphper::FIND_OR & $mode); |
|
44 | - }; |
|
45 | - } |
|
40 | + if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true; |
|
41 | + else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false; |
|
42 | + } |
|
43 | + return !(Maphper::FIND_OR & $mode); |
|
44 | + }; |
|
45 | + } |
|
46 | 46 | |
47 | - private function getIfFieldMatches($key, $val, $data, $mode) { |
|
48 | - if (is_numeric($key) && is_array($val)) { |
|
49 | - return $this->getSearchFieldFunction($val, $key)($data); |
|
50 | - } |
|
51 | - else if (!isset($data->$key)) return false; |
|
52 | - else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val)) |
|
53 | - return in_array($data->$key, $val); |
|
54 | - else |
|
55 | - return $this->processFilter($mode, $val, $data->$key); |
|
56 | - } |
|
47 | + private function getIfFieldMatches($key, $val, $data, $mode) { |
|
48 | + if (is_numeric($key) && is_array($val)) { |
|
49 | + return $this->getSearchFieldFunction($val, $key)($data); |
|
50 | + } |
|
51 | + else if (!isset($data->$key)) return false; |
|
52 | + else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val)) |
|
53 | + return in_array($data->$key, $val); |
|
54 | + else |
|
55 | + return $this->processFilter($mode, $val, $data->$key); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) { |
59 | - return $function($this->findByField($criteria)); |
|
60 | - } |
|
59 | + return $function($this->findByField($criteria)); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | public function deleteById($id) { |
63 | - unset($this->data[$id]); |
|
64 | - } |
|
63 | + unset($this->data[$id]); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public function deleteByField(array $fields) { |
67 | - foreach ($this->findByField($fields) as $val) unset($this->data[$val->{$this->id[0]}]); |
|
68 | - } |
|
67 | + foreach ($this->findByField($fields) as $val) unset($this->data[$val->{$this->id[0]}]); |
|
68 | + } |
|
69 | 69 | |
70 | - public function save($data) { |
|
71 | - if (isset($data->{$this->id[0]})) { |
|
72 | - $id = $data->{$this->id[0]}; |
|
73 | - } |
|
74 | - else { |
|
75 | - $id = count($this->data); |
|
76 | - $data->{$this->id[0]} = $id; |
|
77 | - } |
|
70 | + public function save($data) { |
|
71 | + if (isset($data->{$this->id[0]})) { |
|
72 | + $id = $data->{$this->id[0]}; |
|
73 | + } |
|
74 | + else { |
|
75 | + $id = count($this->data); |
|
76 | + $data->{$this->id[0]} = $id; |
|
77 | + } |
|
78 | 78 | |
79 | - $this->data[$id] = (object)array_merge($this->findById($id), (array)$data); |
|
80 | - } |
|
79 | + $this->data[$id] = (object)array_merge($this->findById($id), (array)$data); |
|
80 | + } |
|
81 | 81 | |
82 | - public function getErrors() { |
|
83 | - return []; |
|
84 | - } |
|
82 | + public function getErrors() { |
|
83 | + return []; |
|
84 | + } |
|
85 | 85 | |
86 | - private function getOrderFunction($order, $columns) { |
|
87 | - return function($a, $b) use ($order, $columns) { |
|
88 | - foreach (explode(',', $columns) as $column) { |
|
89 | - $aColumn = $a->$column; |
|
90 | - $bColumn = $b->$column; |
|
91 | - if ($aColumn === $bColumn) { |
|
92 | - $sortVal = 0; |
|
93 | - continue; |
|
94 | - } |
|
95 | - else $sortVal = ($aColumn < $bColumn) ? -1 : 1; |
|
96 | - break; |
|
97 | - } |
|
98 | - if ($order === 'desc') return -$sortVal; |
|
99 | - else return $sortVal; |
|
100 | - }; |
|
101 | - } |
|
86 | + private function getOrderFunction($order, $columns) { |
|
87 | + return function($a, $b) use ($order, $columns) { |
|
88 | + foreach (explode(',', $columns) as $column) { |
|
89 | + $aColumn = $a->$column; |
|
90 | + $bColumn = $b->$column; |
|
91 | + if ($aColumn === $bColumn) { |
|
92 | + $sortVal = 0; |
|
93 | + continue; |
|
94 | + } |
|
95 | + else $sortVal = ($aColumn < $bColumn) ? -1 : 1; |
|
96 | + break; |
|
97 | + } |
|
98 | + if ($order === 'desc') return -$sortVal; |
|
99 | + else return $sortVal; |
|
100 | + }; |
|
101 | + } |
|
102 | 102 | |
103 | - private function processFilter($mode, $expected, $actual) { |
|
104 | - if (Maphper::FIND_NOT & $mode) return $expected != $actual; |
|
105 | - else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual; |
|
106 | - else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual; |
|
107 | - else if (Maphper::FIND_GREATER & $mode) return $expected < $actual; |
|
108 | - else if (Maphper::FIND_LESS & $mode) return $expected > $actual; |
|
109 | - else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1]; |
|
110 | - else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual); |
|
111 | - return $expected == $actual; |
|
112 | - } |
|
103 | + private function processFilter($mode, $expected, $actual) { |
|
104 | + if (Maphper::FIND_NOT & $mode) return $expected != $actual; |
|
105 | + else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual; |
|
106 | + else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual; |
|
107 | + else if (Maphper::FIND_GREATER & $mode) return $expected < $actual; |
|
108 | + else if (Maphper::FIND_LESS & $mode) return $expected > $actual; |
|
109 | + else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1]; |
|
110 | + else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual); |
|
111 | + return $expected == $actual; |
|
112 | + } |
|
113 | 113 | } |