@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function get($attribute) |
| 91 | 91 | { |
| 92 | - list($attribute, $subattribute) = array_pad(explode('.', $attribute, 2), 2, null); |
|
| 92 | + list($attribute, $subattribute) = array_pad(explode('.', $attribute, 2), 2, null); |
|
| 93 | 93 | |
| 94 | 94 | if ($this->hasRelation($attribute)) { |
| 95 | 95 | $related = $this->related($attribute); |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | $split = explode('\\', get_class($this)); |
| 156 | 156 | $class = end($split); |
| 157 | 157 | |
| 158 | - return preg_replace_callback('/([A-Z])/', function ($matches) { |
|
| 159 | - return '_' . strtolower($matches[1]); |
|
| 160 | - }, lcfirst($class)) . 's'; |
|
| 158 | + return preg_replace_callback('/([A-Z])/', function($matches) { |
|
| 159 | + return '_'.strtolower($matches[1]); |
|
| 160 | + }, lcfirst($class)).'s'; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | $storage = $instance->storage(); |
| 412 | 412 | |
| 413 | 413 | if (!$storage instanceof Searchable) { |
| 414 | - throw new Exception(get_class($instance) . ' storage is not searchable'); |
|
| 414 | + throw new Exception(get_class($instance).' storage is not searchable'); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $attributes = $attributes ?: $instance->defaultSearchAttributes(); |
@@ -476,13 +476,13 @@ discard block |
||
| 476 | 476 | $storage = $instance->storage(); |
| 477 | 477 | |
| 478 | 478 | if (!$storage instanceof Queryable) { |
| 479 | - throw new Exception(get_class($instance) . ' storage is not queryable'); |
|
| 479 | + throw new Exception(get_class($instance).' storage is not queryable'); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | $query = new Query($instance->table()); |
| 483 | 483 | $builder = new Builder($query, $storage); |
| 484 | 484 | |
| 485 | - $builder->callback(function ($result) use ($instance) { |
|
| 485 | + $builder->callback(function($result) use ($instance) { |
|
| 486 | 486 | return $instance::hydrate($result->data); |
| 487 | 487 | }); |
| 488 | 488 | |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | // Storage must be modifiable in order to save |
| 565 | 565 | if (!$storage instanceof Modifiable) { |
| 566 | - throw new Exception($class . ' storage is not modifiable'); |
|
| 566 | + throw new Exception($class.' storage is not modifiable'); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | // Create or update the model in storage |
@@ -797,6 +797,6 @@ discard block |
||
| 797 | 797 | return $this->relation($method); |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - throw new Exception('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
| 800 | + throw new Exception('Call to undefined method '.get_class($this).'::'.$method.'()'); |
|
| 801 | 801 | } |
| 802 | 802 | } |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace Darya\ORM; |
| 3 | 3 | |
| 4 | 4 | use Darya\ORM\Record; |
| 5 | -use Darya\Storage\Readable; |
|
| 6 | -use Darya\Storage\Modifiable; |
|
| 7 | 5 | use Darya\Storage\Queryable; |
| 8 | 6 | use Darya\Storage\Query\Builder; |
| 9 | 7 | use Exception; |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | $split = explode('\\', $class); |
| 248 | 248 | $class = end($split); |
| 249 | 249 | |
| 250 | - return preg_replace_callback('/([A-Z])/', function ($matches) { |
|
| 251 | - return '_' . strtolower($matches[1]); |
|
| 250 | + return preg_replace_callback('/([A-Z])/', function($matches) { |
|
| 251 | + return '_'.strtolower($matches[1]); |
|
| 252 | 252 | }, lcfirst($class)); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | protected function prepareForeignKey($class) |
| 262 | 262 | { |
| 263 | - return $this->delimitClass($class) . '_id'; |
|
| 263 | + return $this->delimitClass($class).'_id'; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | foreach (static::arrayify($instances) as $instance) { |
| 430 | 430 | if (!$instance instanceof $class) { |
| 431 | - throw new Exception('Related models must be an instance of ' . $class); |
|
| 431 | + throw new Exception('Related models must be an instance of '.$class); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | ->filters($this->filter()) |
| 579 | 579 | ->orders($this->order()); |
| 580 | 580 | |
| 581 | - $builder->callback(function ($result) use ($class) { |
|
| 581 | + $builder->callback(function($result) use ($class) { |
|
| 582 | 582 | return $class::hydrate($result->data); |
| 583 | 583 | }); |
| 584 | 584 | |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | |
| 789 | 789 | // Filter the IDs to associate and dissociate if any have been given |
| 790 | 790 | if (!empty($ids)) { |
| 791 | - $filter = function ($instance) use ($ids) { |
|
| 791 | + $filter = function($instance) use ($ids) { |
|
| 792 | 792 | return in_array($instance->id(), $ids); |
| 793 | 793 | }; |
| 794 | 794 | |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | // Dissociate, then associate |
| 805 | - if (!empty($detached)) { |
|
| 805 | + if (!empty($detached)) { |
|
| 806 | 806 | $this->dissociate($detached); |
| 807 | 807 | } |
| 808 | 808 | |