@@ -66,17 +66,17 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public static function getStorage($connectionName = self::DEFAULT_CONNECTION_NAME) |
| 68 | 68 | { |
| 69 | - if (! key_exists($connectionName, self::$connections)) { |
|
| 70 | - throw new InvalidArgumentException("No connection named '" . $connectionName . "' has been configured"); |
|
| 69 | + if (!key_exists($connectionName, self::$connections)) { |
|
| 70 | + throw new InvalidArgumentException("No connection named '".$connectionName."' has been configured"); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $connection = self::$connections[$connectionName]; |
| 74 | 74 | $uniqueName = self::getUniqueName($connectionName); |
| 75 | 75 | |
| 76 | - if (! key_exists($uniqueName, $GLOBALS)) { |
|
| 76 | + if (!key_exists($uniqueName, $GLOBALS)) { |
|
| 77 | 77 | $GLOBALS[$uniqueName] = null; |
| 78 | 78 | } |
| 79 | - if (! $GLOBALS[$uniqueName] instanceof Storage) { |
|
| 79 | + if (!$GLOBALS[$uniqueName] instanceof Storage) { |
|
| 80 | 80 | switch ($connection['type']) { |
| 81 | 81 | case 'mongodb': |
| 82 | 82 | self::createMongoStorage($connectionName); |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $connection = self::$connections[$connectionName]; |
| 120 | 120 | $uniqueName = self::getUniqueName($connectionName); |
| 121 | 121 | |
| 122 | - $dsn = $connection['type'] . ':host=' . $connection['host'] . ';dbname=' . $connection['database']; |
|
| 123 | - $connection['port'] != null ? $dsn = $dsn . ';port=' . $connection['port'] : null; |
|
| 122 | + $dsn = $connection['type'].':host='.$connection['host'].';dbname='.$connection['database']; |
|
| 123 | + $connection['port'] != null ? $dsn = $dsn.';port='.$connection['port'] : null; |
|
| 124 | 124 | |
| 125 | 125 | if ($connection['type'] == 'sqlite' |
| 126 | 126 | && (file_exists($connection['database']) || $connection['database'] == ':memory:')) { |
| 127 | - $dsn = $connection['type'] . ':' . $connection['database']; |
|
| 127 | + $dsn = $connection['type'].':'.$connection['database']; |
|
| 128 | 128 | } |
| 129 | 129 | try { |
| 130 | 130 | $pdo = new PDO($dsn, $connection['username'], $connection['password'], $connection['driverOptions']); |
| 131 | 131 | $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 132 | 132 | $GLOBALS[$uniqueName] = new SqlStorage($pdo); |
| 133 | 133 | } catch (PDOException $e) { |
| 134 | - throw new RuntimeException('Connection failed: ' . $e->getMessage()); |
|
| 134 | + throw new RuntimeException('Connection failed: '.$e->getMessage()); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | $connection = self::$connections[$connectionName]; |
| 151 | 151 | $uniqueName = self::getUniqueName($connectionName); |
| 152 | 152 | |
| 153 | - $dsn = $connection['type'] . '://' . $connection['host']; |
|
| 154 | - $connection['port'] != null ? $dsn = $dsn . ':' . $connection['port'] : null; |
|
| 153 | + $dsn = $connection['type'].'://'.$connection['host']; |
|
| 154 | + $connection['port'] != null ? $dsn = $dsn.':'.$connection['port'] : null; |
|
| 155 | 155 | try { |
| 156 | 156 | if (is_array($connection['driverOptions'])) { |
| 157 | 157 | $mongo = new Mongo($dsn, $connection['driverOptions']); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $mongoDb = $mongo->selectDB($connection['database']); |
| 164 | 164 | $GLOBALS[$uniqueName] = new MongoStorage($mongoDb); |
| 165 | 165 | } catch (MongoConnnectionException $e) { |
| 166 | - throw new RuntimeException('Connection failed: ' . $e->getMessage()); |
|
| 166 | + throw new RuntimeException('Connection failed: '.$e->getMessage()); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public static function setModelPath($path) |
| 224 | 224 | { |
| 225 | - if (! file_exists($path)) { |
|
| 226 | - throw new InvalidArgumentException('Model path could not be found:' . $path); |
|
| 225 | + if (!file_exists($path)) { |
|
| 226 | + throw new InvalidArgumentException('Model path could not be found:'.$path); |
|
| 227 | 227 | } |
| 228 | 228 | self::$modelPath = $path; |
| 229 | 229 | } |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | $drivers[] = 'mongodb'; |
| 309 | 309 | $drivers[] = 'solr'; |
| 310 | 310 | |
| 311 | - if (! in_array($type, $drivers)) { |
|
| 312 | - $message = 'Only pdo supported sql databases, solr and mongo is supported at the moment.(' . $type . ')'; |
|
| 311 | + if (!in_array($type, $drivers)) { |
|
| 312 | + $message = 'Only pdo supported sql databases, solr and mongo is supported at the moment.('.$type.')'; |
|
| 313 | 313 | throw new InvalidArgumentException($message); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -371,6 +371,6 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | protected static function getUniqueName($connectionName) |
| 373 | 373 | { |
| 374 | - return "TickConnection:" . $connectionName; |
|
| 374 | + return "TickConnection:".$connectionName; |
|
| 375 | 375 | } |
| 376 | 376 | } |
@@ -101,22 +101,22 @@ discard block |
||
| 101 | 101 | ) { |
| 102 | 102 | |
| 103 | 103 | if (count($fields) > 0) { |
| 104 | - $select = "`" . implode("`,`", $fields) . "`"; |
|
| 104 | + $select = "`".implode("`,`", $fields)."`"; |
|
| 105 | 105 | } else { |
| 106 | 106 | $select = '*'; |
| 107 | 107 | } |
| 108 | 108 | $sql = "SELECT $select |
| 109 | - FROM `" . $collection . "` " . |
|
| 110 | - $this->prepareCriteria($criterias) . " " . |
|
| 111 | - $this->orderBy($order, $direction) . " " . |
|
| 112 | - $this->limit($limit, $offset) . ";"; |
|
| 109 | + FROM `".$collection."` ". |
|
| 110 | + $this->prepareCriteria($criterias)." ". |
|
| 111 | + $this->orderBy($order, $direction)." ". |
|
| 112 | + $this->limit($limit, $offset).";"; |
|
| 113 | 113 | try { |
| 114 | 114 | $statement = $this->connection->prepare($sql); |
| 115 | 115 | $statement->execute($this->criteria($criterias)); |
| 116 | 116 | return $statement->fetchAll(PDO::FETCH_ASSOC); |
| 117 | 117 | } catch (PDOException $e) { |
| 118 | - $message = 'Query : "' . |
|
| 119 | - self::interpolateQuery($sql, $this->criteria($criterias)) . '" returned error : ' . $e->getMessage(); |
|
| 118 | + $message = 'Query : "'. |
|
| 119 | + self::interpolateQuery($sql, $this->criteria($criterias)).'" returned error : '.$e->getMessage(); |
|
| 120 | 120 | throw new RuntimeException($message); |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | private function limit($limit, $offset) |
| 135 | 135 | { |
| 136 | - if (! $offset == '') { |
|
| 137 | - return 'LIMIT ' . $offset . ',' . $limit; |
|
| 138 | - } elseif (! $limit == '') { |
|
| 139 | - return 'LIMIT ' . $limit; |
|
| 136 | + if (!$offset == '') { |
|
| 137 | + return 'LIMIT '.$offset.','.$limit; |
|
| 138 | + } elseif (!$limit == '') { |
|
| 139 | + return 'LIMIT '.$limit; |
|
| 140 | 140 | } |
| 141 | 141 | return ''; |
| 142 | 142 | } |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | private function orderBy(array $order, $direction = true) |
| 155 | 155 | { |
| 156 | - if (! empty($order)) { |
|
| 156 | + if (!empty($order)) { |
|
| 157 | 157 | $count = count($order); |
| 158 | 158 | $orderString = array(); |
| 159 | 159 | $orderString[] = 'ORDER BY'; |
| 160 | 160 | for ($i = 0; $count > $i; $i ++) { |
| 161 | 161 | if ($i == 0) { |
| 162 | - $orderString[] = '`' . $order[$i] . '`'; |
|
| 162 | + $orderString[] = '`'.$order[$i].'`'; |
|
| 163 | 163 | } else { |
| 164 | - $orderString[] = ', `' . $order[$i] . '`'; |
|
| 164 | + $orderString[] = ', `'.$order[$i].'`'; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | $orderString[] = $direction ? 'ASC' : 'DESC'; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | private function criteria(array $criterias) |
| 182 | 182 | { |
| 183 | 183 | $where = array(); |
| 184 | - if (! empty($criterias)) { |
|
| 184 | + if (!empty($criterias)) { |
|
| 185 | 185 | foreach ($criterias as $criteria) { |
| 186 | 186 | if ($criteria['value'] instanceof DateTime) { |
| 187 | 187 | $where[] = $criteria['value']->format(DateTime::ISO8601); |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | private function prepareCriteria(array $criterias) |
| 205 | 205 | { |
| 206 | - if (! empty($criterias)) { |
|
| 206 | + if (!empty($criterias)) { |
|
| 207 | 207 | $where = array(); |
| 208 | 208 | $where[] = 'WHERE '; |
| 209 | 209 | foreach ($criterias as $criteria) { |
| 210 | 210 | if (sizeof($where) > 1) { |
| 211 | 211 | $where[] = ' AND '; |
| 212 | 212 | } |
| 213 | - $where[] = '`' . $criteria['property'] . '` ' . $criteria['condition'] . ' ?'; |
|
| 213 | + $where[] = '`'.$criteria['property'].'` '.$criteria['condition'].' ?'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return implode('', $where); |
@@ -241,15 +241,15 @@ discard block |
||
| 241 | 241 | $values[] = $value['value']; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - $sql = "INSERT INTO `" . $collection . "` (" . implode(', ', array_keys($data)) . ") |
|
| 245 | - VALUES (" . implode(', ', array_fill(0, count($data), '?')) . ");"; |
|
| 244 | + $sql = "INSERT INTO `".$collection."` (".implode(', ', array_keys($data)).") |
|
| 245 | + VALUES (" . implode(', ', array_fill(0, count($data), '?')).");"; |
|
| 246 | 246 | |
| 247 | 247 | try { |
| 248 | 248 | $statement = $this->connection->prepare($sql); |
| 249 | 249 | $statement->execute($values); |
| 250 | 250 | return $this->connection->lastInsertId(); |
| 251 | 251 | } catch (PDOException $e) { |
| 252 | - $message = 'Query : "' . self::interpolateQuery($sql, $values) . '" returned error : ' . $e->getMessage(); |
|
| 252 | + $message = 'Query : "'.self::interpolateQuery($sql, $values).'" returned error : '.$e->getMessage(); |
|
| 253 | 253 | throw new RuntimeException($message); |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $setString = array(); |
| 289 | 289 | $values = array(); |
| 290 | 290 | foreach ($data as $field => $value) { |
| 291 | - $setString[] = '`' . $field . "` = ?"; |
|
| 291 | + $setString[] = '`'.$field."` = ?"; |
|
| 292 | 292 | |
| 293 | 293 | if ($value['type'] == 'DateTime') { |
| 294 | 294 | $values[] = self::convertDateTime($value['value']); |
@@ -296,14 +296,14 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | $values[] = $value['value']; |
| 298 | 298 | } |
| 299 | - $sql = "UPDATE `" . $collection . "` |
|
| 300 | - SET " . implode(', ', $setString) . " " . $this->prepareCriteria($criterias) . ";"; |
|
| 299 | + $sql = "UPDATE `".$collection."` |
|
| 300 | + SET " . implode(', ', $setString)." ".$this->prepareCriteria($criterias).";"; |
|
| 301 | 301 | $values = array_merge($values, $this->criteria($criterias)); |
| 302 | 302 | try { |
| 303 | 303 | $statement = $this->connection->prepare($sql); |
| 304 | 304 | $statement->execute($values); |
| 305 | 305 | } catch (PDOException $e) { |
| 306 | - $message = 'Query : "' . self::interpolateQuery($sql, $values) . '" returned error : ' . $e->getMessage(); |
|
| 306 | + $message = 'Query : "'.self::interpolateQuery($sql, $values).'" returned error : '.$e->getMessage(); |
|
| 307 | 307 | throw new RuntimeException($message); |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function remove($collection, array $criterias) |
| 323 | 323 | { |
| 324 | - $sql = "DELETE FROM `" . $collection . "` " . $this->prepareCriteria($criterias) . ";"; |
|
| 324 | + $sql = "DELETE FROM `".$collection."` ".$this->prepareCriteria($criterias).";"; |
|
| 325 | 325 | try { |
| 326 | 326 | $statement = $this->connection->prepare($sql); |
| 327 | 327 | $statement->execute($this->criteria($criterias)); |
| 328 | 328 | } catch (PDOException $e) { |
| 329 | - $message = 'Query : "' . |
|
| 330 | - self::interpolateQuery($sql, $this->criteria($criterias)) . '" returned error : ' . $e->getMessage(); |
|
| 329 | + $message = 'Query : "'. |
|
| 330 | + self::interpolateQuery($sql, $this->criteria($criterias)).'" returned error : '.$e->getMessage(); |
|
| 331 | 331 | throw new RuntimeException($message); |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | // build a regular expression for each parameter |
| 385 | 385 | foreach ($params as $key => $value) { |
| 386 | 386 | if (is_string($key)) { |
| 387 | - $keys[] = '/:' . $key . '/'; |
|
| 387 | + $keys[] = '/:'.$key.'/'; |
|
| 388 | 388 | } else { |
| 389 | 389 | $keys[] = '/[?]/'; |
| 390 | 390 | } |
@@ -10,15 +10,15 @@ |
||
| 10 | 10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 11 | 11 | * @link https://github.com/localgod/php-tick php-tick |
| 12 | 12 | */ |
| 13 | - use \MongoDB; |
|
| 14 | - use \MongoId; |
|
| 15 | - use \MongoRegex; |
|
| 16 | - use \MongoConnectionException; |
|
| 17 | - use \MongoCursorTimeoutException; |
|
| 18 | - use \MongoDate; |
|
| 19 | - use \Exception; |
|
| 20 | - use \RuntimeException; |
|
| 21 | - use \DateTime; |
|
| 13 | + use \MongoDB; |
|
| 14 | + use \MongoId; |
|
| 15 | + use \MongoRegex; |
|
| 16 | + use \MongoConnectionException; |
|
| 17 | + use \MongoCursorTimeoutException; |
|
| 18 | + use \MongoDate; |
|
| 19 | + use \Exception; |
|
| 20 | + use \RuntimeException; |
|
| 21 | + use \DateTime; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Tick mongo storage implementation |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | return $result; |
| 132 | 132 | } catch (MongoConnectionException $e) { |
| 133 | - throw new RuntimeException('Query : returned error : ' . $e->getMessage()); |
|
| 133 | + throw new RuntimeException('Query : returned error : '.$e->getMessage()); |
|
| 134 | 134 | } catch (MongoCursorTimeoutException $e) { |
| 135 | - throw new RuntimeException('Query : returned error : ' . $e->getMessage()); |
|
| 135 | + throw new RuntimeException('Query : returned error : '.$e->getMessage()); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | private function criteria(array $criterias) |
| 148 | 148 | { |
| 149 | - if (! empty($criterias)) { |
|
| 149 | + if (!empty($criterias)) { |
|
| 150 | 150 | $where = array(); |
| 151 | 151 | $map = array( |
| 152 | 152 | '<' => '$lt', |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | if (array_key_exists($criteria['condition'], $map)) { |
| 165 | 165 | $where[$criteria['property']] = array( |
| 166 | - '' . $map[$criteria['condition']] . '' => $value |
|
| 166 | + ''.$map[$criteria['condition']].'' => $value |
|
| 167 | 167 | ); |
| 168 | 168 | } elseif (preg_match('/^like$/i', $criteria['condition'])) { |
| 169 | - $regxp = '/' . (substr($value, 0, 1) == '%' ? '' : '^') . |
|
| 170 | - str_replace('%', '', $value) . (substr($value, - 1) == '%' ? '' : '$') . '/i'; |
|
| 169 | + $regxp = '/'.(substr($value, 0, 1) == '%' ? '' : '^'). |
|
| 170 | + str_replace('%', '', $value).(substr($value, - 1) == '%' ? '' : '$').'/i'; |
|
| 171 | 171 | $where[$criteria['property']] = new MongoRegex($regxp); |
| 172 | 172 | } elseif ($criteria['condition'] == '=') { |
| 173 | 173 | $where[$criteria['property']] = $value; |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $mongoCollection = $this->connection->selectCollection($collection); |
| 219 | 219 | $mongoCollection->insert($setArray); |
| 220 | 220 | } catch (Exception $e) { |
| 221 | - echo $e->getMessage() . "\n"; |
|
| 222 | - echo 'Failed insert in collection > $collection: ' . implode(', ', $setArray) . "\n"; |
|
| 221 | + echo $e->getMessage()."\n"; |
|
| 222 | + echo 'Failed insert in collection > $collection: '.implode(', ', $setArray)."\n"; |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
@@ -281,13 +281,13 @@ |
||
| 281 | 281 | foreach ($criterias as $crit) { |
| 282 | 282 | switch ($crit['condition']) { |
| 283 | 283 | case '>=': |
| 284 | - $queryParts[] = $crit['property'] . ':[' . $crit['value'] . ' TO *]'; |
|
| 284 | + $queryParts[] = $crit['property'].':['.$crit['value'].' TO *]'; |
|
| 285 | 285 | break; |
| 286 | 286 | case '<=': |
| 287 | - $queryParts[] = $crit['property'] . ':[* TO ' . $crit['value'] . ']'; |
|
| 287 | + $queryParts[] = $crit['property'].':[* TO '.$crit['value'].']'; |
|
| 288 | 288 | break; |
| 289 | 289 | case '=': |
| 290 | - $queryParts[] = $crit['property'] . ':"' . $crit['value'] . '"'; |
|
| 290 | + $queryParts[] = $crit['property'].':"'.$crit['value'].'"'; |
|
| 291 | 291 | break; |
| 292 | 292 | case 'MATCHES': |
| 293 | 293 | $queryParts[] = $crit['value']; |
@@ -62,9 +62,9 @@ |
||
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if (! empty($criterias)) { |
|
| 65 | + if (!empty($criterias)) { |
|
| 66 | 66 | $result = $this->get(); |
| 67 | - if (! empty($result)) { |
|
| 67 | + if (!empty($result)) { |
|
| 68 | 68 | return true; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 11 | 11 | * @link https://github.com/localgod/php-tick php-tick |
| 12 | 12 | */ |
| 13 | - use \Iterator; |
|
| 14 | - use \DateTime; |
|
| 15 | - use \InvalidArgumentException; |
|
| 13 | + use \Iterator; |
|
| 14 | + use \DateTime; |
|
| 15 | + use \InvalidArgumentException; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Result |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | private function getResult() |
| 111 | 111 | { |
| 112 | - if (! isset($this->result)) { |
|
| 112 | + if (!isset($this->result)) { |
|
| 113 | 113 | $fieldNames = $this->model->listFieldNames(); |
| 114 | 114 | $this->result = $this->model->getStorage()->get( |
| 115 | 115 | $this->model->getCollectionName(), |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function orderBy($properties, $direction = true) |
| 246 | 246 | { |
| 247 | - if (! is_bool($direction)) { |
|
| 247 | + if (!is_bool($direction)) { |
|
| 248 | 248 | throw new InvalidArgumentException('Order direction must be boolean. (true = ascending, false descending)'); |
| 249 | 249 | } |
| 250 | 250 | $this->direction = $direction; |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | public function offset($offset) |
| 284 | 284 | { |
| 285 | 285 | $this->offset = $offset; |
| 286 | - if (! is_numeric($this->limit) && ! $this->limit >= 0) { |
|
| 286 | + if (!is_numeric($this->limit) && !$this->limit >= 0) { |
|
| 287 | 287 | $this->limit = self::DEFAULT_LIMIT; // This is a arbitrary number! |
| 288 | - trigger_error('Limit was not specifically set, so Tick defaulted to ' . self::DEFAULT_LIMIT, E_USER_NOTICE); |
|
| 288 | + trigger_error('Limit was not specifically set, so Tick defaulted to '.self::DEFAULT_LIMIT, E_USER_NOTICE); |
|
| 289 | 289 | } |
| 290 | 290 | return $this; |
| 291 | 291 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $meta = $this->model->getMetadata(); |
| 366 | 366 | $fields = $meta["fields"]; |
| 367 | 367 | |
| 368 | - if (! $this->isEmpty()) { |
|
| 368 | + if (!$this->isEmpty()) { |
|
| 369 | 369 | foreach ($this->result[$position] as $field => $value) { |
| 370 | 370 | $property = $fields[$field]["property"]; |
| 371 | 371 | $propertyType = $fields[$field]["type"]; |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 11 | 11 | * @link https://github.com/localgod/php-tick php-tick |
| 12 | 12 | */ |
| 13 | - use \ReflectionClass; |
|
| 14 | - use \InvalidArgumentException; |
|
| 13 | + use \ReflectionClass; |
|
| 14 | + use \InvalidArgumentException; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Type handler for Tick |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | protected function isValidType($property, $value) |
| 47 | 47 | { |
| 48 | 48 | $type = $this->propertyType($property); |
| 49 | - $value = is_numeric($value) ? $value + 1 - 1 : $value;//Force to be a number |
|
| 49 | + $value = is_numeric($value) ? $value + 1 - 1 : $value; //Force to be a number |
|
| 50 | 50 | |
| 51 | 51 | if ($type == 'integer' && is_numeric($value) && preg_match('/^[0-9]+$/', $value)) { |
| 52 | 52 | $this->isValidLength($property, $value); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function getConnectionName() |
| 80 | 80 | { |
| 81 | - if (! key_exists(get_class($this), self::$connectionNameMap)) { |
|
| 81 | + if (!key_exists(get_class($this), self::$connectionNameMap)) { |
|
| 82 | 82 | $regExp = '/@connection[[:blank:]]+([a-zA-Z0-9_]+)/'; |
| 83 | 83 | $matches = array(); |
| 84 | 84 | if (preg_match($regExp, $this->getClassComment(), $matches)) { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function getCollectionName() |
| 113 | 113 | { |
| 114 | - if (! key_exists(get_class($this), self::$collectionNameMap)) { |
|
| 114 | + if (!key_exists(get_class($this), self::$collectionNameMap)) { |
|
| 115 | 115 | $regExp = '/@collection[[:blank:]]+([a-zA-Z0-9_]+)/'; |
| 116 | 116 | $matches = array(); |
| 117 | 117 | if (preg_match($regExp, $this->getClassComment(), $matches)) { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | if (in_array($name, $this->listPropertyNames())) { |
| 213 | 213 | return $this->$name; |
| 214 | 214 | } |
| 215 | - throw new Exception('Tried to access unknown property: ' . $name); |
|
| 215 | + throw new Exception('Tried to access unknown property: '.$name); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | if (is_object($this->$property) && get_class($this->$property) == 'DateTime') { |
| 231 | 231 | $date = $this->$property; |
| 232 | 232 | $date->format('Y-m-d H:i:s'); |
| 233 | - $out .= $property . ' => ' . $date->format('Y-m-d H:i:s'); |
|
| 233 | + $out .= $property.' => '.$date->format('Y-m-d H:i:s'); |
|
| 234 | 234 | } else { |
| 235 | - $out .= $property . ' => ' . $this->$property; |
|
| 235 | + $out .= $property.' => '.$this->$property; |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | return $out; |
@@ -252,13 +252,13 @@ discard block |
||
| 252 | 252 | { |
| 253 | 253 | $propertyName = lcfirst(str_replace('get', '', $name)); |
| 254 | 254 | |
| 255 | - if (! $this->propertyExists($propertyName)) { |
|
| 256 | - $message = 'Call to undefined method ' . get_class($this) . '::' . $name; |
|
| 255 | + if (!$this->propertyExists($propertyName)) { |
|
| 256 | + $message = 'Call to undefined method '.get_class($this).'::'.$name; |
|
| 257 | 257 | throw new BadMethodCallException($message); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if (sizeof($arguments) != 0) { |
| 261 | - $message = 'Method ' . get_class($this) . '::' . $name . ' does not take any arguments'; |
|
| 261 | + $message = 'Method '.get_class($this).'::'.$name.' does not take any arguments'; |
|
| 262 | 262 | throw new InvalidArgumentException($message); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $propertyName = lcfirst(str_replace('set', '', $name)); |
| 299 | 299 | |
| 300 | - if (! $this->propertyExists($propertyName)) { |
|
| 301 | - $message = 'Call to undefined method ' . get_class($this) . '::' . $name; |
|
| 300 | + if (!$this->propertyExists($propertyName)) { |
|
| 301 | + $message = 'Call to undefined method '.get_class($this).'::'.$name; |
|
| 302 | 302 | throw new BadMethodCallException($message); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | if (sizeof($arguments) != 1) { |
| 306 | - $message = 'Method ' . get_class($this) . '::' . $name . ' takes only one arguments'; |
|
| 306 | + $message = 'Method '.get_class($this).'::'.$name.' takes only one arguments'; |
|
| 307 | 307 | throw new InvalidArgumentException($message); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | if (key_exists("property", $prop["fields"][$field])) { |
| 430 | 430 | return $prop["fields"][$field]["property"]; |
| 431 | 431 | } |
| 432 | - throw new RuntimeException('Field "' . $field . '" has no property match'); |
|
| 432 | + throw new RuntimeException('Field "'.$field.'" has no property match'); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | /** |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $size = $this->getProperty($name, "size"); |
| 463 | 463 | if (isset($size) && $size > 0) { |
| 464 | 464 | if (strlen($value) > $size) { |
| 465 | - $message = 'Should be in the range 0-' . $size . ' characters. Was ' . strlen($value) . '.'; |
|
| 465 | + $message = 'Should be in the range 0-'.$size.' characters. Was '.strlen($value).'.'; |
|
| 466 | 466 | throw new RangeException($message); |
| 467 | 467 | } |
| 468 | 468 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | public function getMetadata() |
| 494 | 494 | { |
| 495 | 495 | $class = get_class($this); |
| 496 | - if (! key_exists($class, self::$propertyMap)) { |
|
| 496 | + if (!key_exists($class, self::$propertyMap)) { |
|
| 497 | 497 | $properties = array(); |
| 498 | 498 | $propertyBasePattern = '/.*@property\s+([a-zA-Z0-9]+)(?:\(([0-9]+)\))?\s+([_a-zA-Z0-9]+)/'; |
| 499 | 499 | $optionsPattern = '/(?P<default><[^>]+>)|(?P<options>[a-z]+)/'; |
@@ -524,13 +524,13 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | if (preg_match_all($optionsPattern, $rest, $matches, PREG_PATTERN_ORDER)) { |
| 526 | 526 | foreach ($matches["default"] as $option) { |
| 527 | - if (! empty($option)) { |
|
| 527 | + if (!empty($option)) { |
|
| 528 | 528 | $property["default"] = substr($option, 1, - 1); |
| 529 | 529 | break; |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | foreach ($matches["options"] as $option) { |
| 533 | - if (! empty($option)) { |
|
| 533 | + if (!empty($option)) { |
|
| 534 | 534 | if (in_array($option, array( |
| 535 | 535 | "null", |
| 536 | 536 | "unique" |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getStorage() |
| 41 | 41 | { |
| 42 | - if (! $this->storage instanceof Storage) { |
|
| 42 | + if (!$this->storage instanceof Storage) { |
|
| 43 | 43 | $this->storage = Manager::getStorage($this->getConnectionName()); |
| 44 | 44 | } |
| 45 | 45 | return $this->storage; |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $data = array(); |
| 62 | 62 | foreach ($this->listPropertyNames() as $property) { |
| 63 | - if ($this->$property === null && ! $this->notNull($property) && ! $insert) { |
|
| 64 | - throw new RuntimeException('Property "' . $property . '" can not be persisted as null'); |
|
| 63 | + if ($this->$property === null && !$this->notNull($property) && !$insert) { |
|
| 64 | + throw new RuntimeException('Property "'.$property.'" can not be persisted as null'); |
|
| 65 | 65 | } |
| 66 | 66 | $data[$this->propertyAlias($property)] = array( |
| 67 | 67 | 'type' => $this->propertyType($property), |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $result = array(); |
| 123 | 123 | foreach ($criterias as $criteria) { |
| 124 | - if (! $this->propertyExists($criteria['property'])) { |
|
| 124 | + if (!$this->propertyExists($criteria['property'])) { |
|
| 125 | 125 | throw new InvalidArgumentException('Unknown property used in get argument.'); |
| 126 | 126 | } |
| 127 | 127 | $result[] = array( |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 11 | 11 | * @link https://github.com/localgod/php-tick php-tick |
| 12 | 12 | */ |
| 13 | - use \RuntimeException; |
|
| 14 | - use \InvalidArgumentException; |
|
| 15 | - use Localgod\Tick\Entity; |
|
| 16 | - use Localgod\Tick\Storage; |
|
| 13 | + use \RuntimeException; |
|
| 14 | + use \InvalidArgumentException; |
|
| 15 | + use Localgod\Tick\Entity; |
|
| 16 | + use Localgod\Tick\Storage; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Record |