@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | protected function checkPropertyExists($name) { |
| 78 | 78 | if (!array_key_exists($name, $this->_properties)) { |
| 79 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] not exists', ERR_ERROR); |
|
| 79 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] not exists', ERR_ERROR); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | protected function checkOverwriteAdjusted($name) { |
| 84 | 84 | if (array_key_exists($name, $this->propertiesAdjusted)) { |
| 85 | - throw new PropertyAccessException('Property [' . get_called_class() . '::' . $name . '] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
| 85 | + throw new PropertyAccessException('Property ['.get_called_class().'::'.$name.'] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @return boolean |
| 132 | 132 | */ |
| 133 | 133 | public function isContainerEmpty() { |
| 134 | - throw new Exception('PropertyHider::isContainerEmpty() is not implemented. You should implement it in class ' . get_called_class()); |
|
| 134 | + throw new Exception('PropertyHider::isContainerEmpty() is not implemented. You should implement it in class '.get_called_class()); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -175,15 +175,15 @@ discard block |
||
| 175 | 175 | $result = null; |
| 176 | 176 | // Now deciding - will we call a protected setter or will we work with protected property |
| 177 | 177 | // Todo - on init recalc all method_exists |
| 178 | - if (method_exists($this, $methodName = $action . ucfirst($name))) { |
|
| 178 | + if (method_exists($this, $methodName = $action.ucfirst($name))) { |
|
| 179 | 179 | // If method exists - just calling it |
| 180 | 180 | // TODO - should return TRUE if value changed or FALSE otherwise |
| 181 | 181 | $result = call_user_func_array(array($this, $methodName), array($value)); |
| 182 | 182 | } elseif ($this->isPropertyActionAvailable($name, $action)) { |
| 183 | 183 | // No setter exists - works directly with protected property |
| 184 | - $result = $this->{$action . 'Property'}($name, $value); |
|
| 184 | + $result = $this->{$action.'Property'}($name, $value); |
|
| 185 | 185 | } else { |
| 186 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] does not have ' . $action . 'ter/property to ' . $action, ERR_ERROR); |
|
| 186 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] does not have '.$action.'ter/property to '.$action, ERR_ERROR); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $result; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @return string |
| 275 | 275 | */ |
| 276 | 276 | protected function adjustPropertyString($name, $diff) { |
| 277 | - return (string)$this->$name . (string)$diff; |
|
| 277 | + return (string) $this->$name.(string) $diff; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | 286 | protected function adjustPropertyArray($name, $diff) { |
| 287 | - $copy = (array)$this->$name; |
|
| 288 | - HelperArray::merge($copy, (array)$diff, HelperArray::MERGE_PHP); |
|
| 287 | + $copy = (array) $this->$name; |
|
| 288 | + HelperArray::merge($copy, (array) $diff, HelperArray::MERGE_PHP); |
|
| 289 | 289 | |
| 290 | 290 | return $copy; |
| 291 | 291 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @return int |
| 298 | 298 | */ |
| 299 | 299 | protected function deltaInteger($name, $diff) { |
| 300 | - return (int)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int)$diff; |
|
| 300 | + return (int) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int) $diff; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @return float |
| 308 | 308 | */ |
| 309 | 309 | protected function deltaDouble($name, $diff) { |
| 310 | - return (float)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float)$diff; |
|
| 310 | + return (float) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float) $diff; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | 319 | protected function deltaString($name, $diff) { |
| 320 | - return (string)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string)$diff; |
|
| 320 | + return (string) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '').(string) $diff; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @return array |
| 328 | 328 | */ |
| 329 | 329 | protected function deltaArray($name, $diff) { |
| 330 | - $copy = (array)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
| 330 | + $copy = (array) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
| 331 | 331 | HelperArray::merge($copy, $diff, HelperArray::MERGE_PHP); |
| 332 | 332 | |
| 333 | 333 | return $copy; |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | // Capitalizing type name |
| 351 | 351 | $methodName = explode(' ', $type); |
| 352 | 352 | array_walk($methodName, 'DbSqlHelper::UCFirstByRef'); |
| 353 | - $methodName = $prefix . implode('', $methodName); |
|
| 353 | + $methodName = $prefix.implode('', $methodName); |
|
| 354 | 354 | |
| 355 | 355 | if (!method_exists($this, $methodName)) { |
| 356 | - throw new ExceptionTypeUnsupported('Type "' . $type . '" is unsupported in PropertyHider::propertyMethodResult'); |
|
| 356 | + throw new ExceptionTypeUnsupported('Type "'.$type.'" is unsupported in PropertyHider::propertyMethodResult'); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return call_user_func(array($this, $methodName), $name, $diff); |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * @param static $that |
| 61 | 61 | */ |
| 62 | 62 | // Alas! No bindTo() method in 5.3 closures! So we should use what we have |
| 63 | - $propertyData[P_DB_ROW_EXPORT] = function ($that, &$row) use ($propertyName, $fieldName) { |
|
| 63 | + $propertyData[P_DB_ROW_EXPORT] = function($that, &$row) use ($propertyName, $fieldName) { |
|
| 64 | 64 | $row[$fieldName] = $that->$propertyName; |
| 65 | 65 | }; |
| 66 | - $propertyData[P_DB_ROW_IMPORT] = function ($that, &$row) use ($propertyName, $fieldName) { |
|
| 66 | + $propertyData[P_DB_ROW_IMPORT] = function($that, &$row) use ($propertyName, $fieldName) { |
|
| 67 | 67 | // TODO: Here should be some conversions to property type |
| 68 | 68 | $that->$propertyName = $row[$fieldName]; |
| 69 | 69 | }; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | // TODO - however for a sake of uniformity may be we should consider use call_user_func |
| 142 | 142 | // call_user_func($propertyData[P_DB_ROW_EXPORT], $this); |
| 143 | 143 | } else { |
| 144 | - throw new \Exception('There is no valid DB row ' . $desc . ' for ' . get_called_class() . '::' . $propertyName); |
|
| 144 | + throw new \Exception('There is no valid DB row '.$desc.' for '.get_called_class().'::'.$propertyName); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | ->setIdField($object->getIdFieldName()) |
| 14 | 14 | ->field('*') |
| 15 | 15 | ->from($object->getTableName()) |
| 16 | - ->where($object->getIdFieldName() . ' = "' . $rowId . '"'); |
|
| 16 | + ->where($object->getIdFieldName().' = "'.$rowId.'"'); |
|
| 17 | 17 | |
| 18 | 18 | $object->importDbRow($stmt->selectRow()); |
| 19 | 19 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function deleteById($object) { |
| 27 | 27 | $db = classSupernova::$gc->db; |
| 28 | 28 | |
| 29 | - $db->doquery("DELETE FROM `{{" . $object->getTableName() . "}}` WHERE `{$object->getIdFieldName()}` = '{$object->dbId}' LIMIT 1;"); |
|
| 29 | + $db->doquery("DELETE FROM `{{".$object->getTableName()."}}` WHERE `{$object->getIdFieldName()}` = '{$object->dbId}' LIMIT 1;"); |
|
| 30 | 30 | |
| 31 | 31 | return $db->db_affected_rows(); |
| 32 | 32 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | $query = array(); |
| 41 | 41 | foreach ($object->exportDbRow(false) as $fieldName => $fieldValue) { |
| 42 | 42 | // TODO: MORE type detection |
| 43 | - if(!is_numeric($fieldValue)) { |
|
| 44 | - $fieldValue = "'" . $db->db_escape($fieldValue) . "'"; |
|
| 43 | + if (!is_numeric($fieldValue)) { |
|
| 44 | + $fieldValue = "'".$db->db_escape($fieldValue)."'"; |
|
| 45 | 45 | } |
| 46 | 46 | $query[] = "`{$fieldName}` = {$fieldValue}"; |
| 47 | 47 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return 0; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $db->doquery("INSERT INTO `{{" . $object->getTableName() . "}}` SET " . $query); |
|
| 55 | + $db->doquery("INSERT INTO `{{".$object->getTableName()."}}` SET ".$query); |
|
| 56 | 56 | |
| 57 | 57 | // TODO Exceptiion if db_insert_id() is empty |
| 58 | 58 | return $object->dbId = $db->db_insert_id(); |