@@ -11,70 +11,70 @@ |
||
11 | 11 | */ |
12 | 12 | class IlluminateDBAdapter implements DBAdapter |
13 | 13 | { |
14 | - /** |
|
15 | - * @var Connection |
|
16 | - */ |
|
17 | - protected $connection; |
|
14 | + /** |
|
15 | + * @var Connection |
|
16 | + */ |
|
17 | + protected $connection; |
|
18 | 18 | |
19 | - /** |
|
20 | - * IlluminateDBAdapter constructor. |
|
21 | - * @param Connection $connection |
|
22 | - */ |
|
23 | - public function __construct(Connection $connection) |
|
24 | - { |
|
25 | - $this->connection = $connection; |
|
26 | - } |
|
19 | + /** |
|
20 | + * IlluminateDBAdapter constructor. |
|
21 | + * @param Connection $connection |
|
22 | + */ |
|
23 | + public function __construct(Connection $connection) |
|
24 | + { |
|
25 | + $this->connection = $connection; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Return a new Query instance for this driver |
|
30 | - * |
|
31 | - * @return QueryAdapter |
|
32 | - */ |
|
33 | - public function getQuery() |
|
34 | - { |
|
35 | - $connection = $this->connection; |
|
28 | + /** |
|
29 | + * Return a new Query instance for this driver |
|
30 | + * |
|
31 | + * @return QueryAdapter |
|
32 | + */ |
|
33 | + public function getQuery() |
|
34 | + { |
|
35 | + $connection = $this->connection; |
|
36 | 36 | |
37 | - $grammar = $connection->getQueryGrammar(); |
|
37 | + $grammar = $connection->getQueryGrammar(); |
|
38 | 38 | |
39 | - $queryBuilder = new QueryBuilder($connection, $grammar, $connection->getPostProcessor()); |
|
39 | + $queryBuilder = new QueryBuilder($connection, $grammar, $connection->getPostProcessor()); |
|
40 | 40 | |
41 | - return new IlluminateQueryAdapter($queryBuilder); |
|
42 | - } |
|
41 | + return new IlluminateQueryAdapter($queryBuilder); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the date format supported by the current connection |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getDateFormat() |
|
50 | - { |
|
51 | - return $this->connection->getQueryGrammar()->getDateFormat(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get the date format supported by the current connection |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getDateFormat() |
|
50 | + { |
|
51 | + return $this->connection->getQueryGrammar()->getDateFormat(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Start a DB transaction on driver that supports it. |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function beginTransaction() |
|
59 | - { |
|
60 | - $this->connection->beginTransaction(); |
|
61 | - } |
|
54 | + /** |
|
55 | + * Start a DB transaction on driver that supports it. |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function beginTransaction() |
|
59 | + { |
|
60 | + $this->connection->beginTransaction(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Commit a DB transaction on driver that supports it. |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function commit() |
|
68 | - { |
|
69 | - $this->connection->commit(); |
|
70 | - } |
|
63 | + /** |
|
64 | + * Commit a DB transaction on driver that supports it. |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function commit() |
|
68 | + { |
|
69 | + $this->connection->commit(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Rollback a DB transaction |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - public function rollback() |
|
77 | - { |
|
78 | - $this->connection->rollBack(); |
|
79 | - } |
|
72 | + /** |
|
73 | + * Rollback a DB transaction |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + public function rollback() |
|
77 | + { |
|
78 | + $this->connection->rollBack(); |
|
79 | + } |
|
80 | 80 | } |
@@ -4,32 +4,32 @@ |
||
4 | 4 | |
5 | 5 | class Manager |
6 | 6 | { |
7 | - /** |
|
8 | - * @var DriverInterface[] |
|
9 | - */ |
|
10 | - protected $drivers = []; |
|
7 | + /** |
|
8 | + * @var DriverInterface[] |
|
9 | + */ |
|
10 | + protected $drivers = []; |
|
11 | 11 | |
12 | - /** |
|
13 | - * Add a Mapping Driver |
|
14 | - * |
|
15 | - * @param DriverInterface $driver |
|
16 | - */ |
|
17 | - public function addDriver(DriverInterface $driver) |
|
18 | - { |
|
19 | - $this->drivers[$driver->getName()] = $driver; |
|
20 | - } |
|
12 | + /** |
|
13 | + * Add a Mapping Driver |
|
14 | + * |
|
15 | + * @param DriverInterface $driver |
|
16 | + */ |
|
17 | + public function addDriver(DriverInterface $driver) |
|
18 | + { |
|
19 | + $this->drivers[$driver->getName()] = $driver; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Get the DBAdapter |
|
24 | - * |
|
25 | - * @param string $driver |
|
26 | - * @param string $connection connection name for drivers supporting multiple connection. |
|
27 | - * @return DriverInterface|void |
|
28 | - */ |
|
29 | - public function getAdapter($driver, $connection = null) |
|
30 | - { |
|
31 | - if (array_key_exists($driver, $this->drivers)) { |
|
32 | - return $this->drivers[$driver]->getAdapter($connection); |
|
33 | - } |
|
34 | - } |
|
22 | + /** |
|
23 | + * Get the DBAdapter |
|
24 | + * |
|
25 | + * @param string $driver |
|
26 | + * @param string $connection connection name for drivers supporting multiple connection. |
|
27 | + * @return DriverInterface|void |
|
28 | + */ |
|
29 | + public function getAdapter($driver, $connection = null) |
|
30 | + { |
|
31 | + if (array_key_exists($driver, $this->drivers)) { |
|
32 | + return $this->drivers[$driver]->getAdapter($connection); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class CapsuleConnectionProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * @var Capsule |
|
11 | - */ |
|
12 | - protected $capsule; |
|
9 | + /** |
|
10 | + * @var Capsule |
|
11 | + */ |
|
12 | + protected $capsule; |
|
13 | 13 | |
14 | - /** |
|
15 | - * CapsuleConnectionProvider constructor. |
|
16 | - * @param Capsule $capsule |
|
17 | - */ |
|
18 | - public function __construct(Capsule $capsule) |
|
19 | - { |
|
20 | - $this->capsule = $capsule; |
|
21 | - } |
|
14 | + /** |
|
15 | + * CapsuleConnectionProvider constructor. |
|
16 | + * @param Capsule $capsule |
|
17 | + */ |
|
18 | + public function __construct(Capsule $capsule) |
|
19 | + { |
|
20 | + $this->capsule = $capsule; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Get a Database connection object |
|
25 | - * |
|
26 | - * @param $name |
|
27 | - * @return \Illuminate\Database\Connection |
|
28 | - */ |
|
29 | - public function connection($name = null) |
|
30 | - { |
|
31 | - return $this->capsule->getConnection($name); |
|
32 | - } |
|
23 | + /** |
|
24 | + * Get a Database connection object |
|
25 | + * |
|
26 | + * @param $name |
|
27 | + * @return \Illuminate\Database\Connection |
|
28 | + */ |
|
29 | + public function connection($name = null) |
|
30 | + { |
|
31 | + return $this->capsule->getConnection($name); |
|
32 | + } |
|
33 | 33 | } |
@@ -4,16 +4,16 @@ |
||
4 | 4 | |
5 | 5 | interface DriverInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * Return the name of the driver |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function getName(); |
|
7 | + /** |
|
8 | + * Return the name of the driver |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function getName(); |
|
12 | 12 | |
13 | - /** |
|
14 | - * Get Analogue DB Adapter |
|
15 | - * @param string $connection connection name for drivers supporting multiple connections |
|
16 | - * @return \Analogue\ORM\Drivers\DBAdapter |
|
17 | - */ |
|
18 | - public function getAdapter($connection = null); |
|
13 | + /** |
|
14 | + * Get Analogue DB Adapter |
|
15 | + * @param string $connection connection name for drivers supporting multiple connections |
|
16 | + * @return \Analogue\ORM\Drivers\DBAdapter |
|
17 | + */ |
|
18 | + public function getAdapter($connection = null); |
|
19 | 19 | } |
@@ -4,42 +4,42 @@ |
||
4 | 4 | |
5 | 5 | class IlluminateDriver implements DriverInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * The Illuminate Connection Provider |
|
9 | - * |
|
10 | - * @var CapsuleConnectionProvider|IlluminateConnectionProvider |
|
11 | - */ |
|
12 | - protected $connectionProvider; |
|
7 | + /** |
|
8 | + * The Illuminate Connection Provider |
|
9 | + * |
|
10 | + * @var CapsuleConnectionProvider|IlluminateConnectionProvider |
|
11 | + */ |
|
12 | + protected $connectionProvider; |
|
13 | 13 | |
14 | - /** |
|
15 | - * IlluminateDriver constructor. |
|
16 | - * @param $connectionProvider |
|
17 | - */ |
|
18 | - public function __construct($connectionProvider) |
|
19 | - { |
|
20 | - $this->connectionProvider = $connectionProvider; |
|
21 | - } |
|
14 | + /** |
|
15 | + * IlluminateDriver constructor. |
|
16 | + * @param $connectionProvider |
|
17 | + */ |
|
18 | + public function __construct($connectionProvider) |
|
19 | + { |
|
20 | + $this->connectionProvider = $connectionProvider; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Return the name of the driver |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function getName() |
|
29 | - { |
|
30 | - return 'illuminate'; |
|
31 | - } |
|
23 | + /** |
|
24 | + * Return the name of the driver |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function getName() |
|
29 | + { |
|
30 | + return 'illuminate'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Get Analogue DBAdapter |
|
35 | - * |
|
36 | - * @param string|null $connection |
|
37 | - * @return IlluminateDBAdapter |
|
38 | - */ |
|
39 | - public function getAdapter($connection = null) |
|
40 | - { |
|
41 | - $connection = $this->connectionProvider->connection($connection); |
|
33 | + /** |
|
34 | + * Get Analogue DBAdapter |
|
35 | + * |
|
36 | + * @param string|null $connection |
|
37 | + * @return IlluminateDBAdapter |
|
38 | + */ |
|
39 | + public function getAdapter($connection = null) |
|
40 | + { |
|
41 | + $connection = $this->connectionProvider->connection($connection); |
|
42 | 42 | |
43 | - return new IlluminateDBAdapter($connection); |
|
44 | - } |
|
43 | + return new IlluminateDBAdapter($connection); |
|
44 | + } |
|
45 | 45 | } |
@@ -4,38 +4,38 @@ |
||
4 | 4 | |
5 | 5 | interface DBAdapter |
6 | 6 | { |
7 | - /** |
|
8 | - * Return's Driver specific Query Implementation |
|
9 | - * |
|
10 | - * @return \Analogue\ORM\Drivers\QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter |
|
11 | - */ |
|
12 | - public function getQuery(); |
|
7 | + /** |
|
8 | + * Return's Driver specific Query Implementation |
|
9 | + * |
|
10 | + * @return \Analogue\ORM\Drivers\QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter |
|
11 | + */ |
|
12 | + public function getQuery(); |
|
13 | 13 | |
14 | - /** |
|
15 | - * Return the Date format used on this adapter |
|
16 | - * |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function getDateFormat(); |
|
14 | + /** |
|
15 | + * Return the Date format used on this adapter |
|
16 | + * |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function getDateFormat(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * Start a DB transaction on driver that supports it. |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function beginTransaction(); |
|
21 | + /** |
|
22 | + * Start a DB transaction on driver that supports it. |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function beginTransaction(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Commit a DB transaction on driver that supports it. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function commit(); |
|
28 | + /** |
|
29 | + * Commit a DB transaction on driver that supports it. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function commit(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Rollback a DB transaction on driver that supports it. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function rollback(); |
|
35 | + /** |
|
36 | + * Rollback a DB transaction on driver that supports it. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function rollback(); |
|
41 | 41 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | interface Mappable |
6 | 6 | { |
7 | - /** |
|
8 | - * Set the object attribute raw values (hydration) |
|
9 | - * |
|
10 | - * @param array $attributes |
|
11 | - */ |
|
12 | - public function setEntityAttributes(array $attributes); |
|
7 | + /** |
|
8 | + * Set the object attribute raw values (hydration) |
|
9 | + * |
|
10 | + * @param array $attributes |
|
11 | + */ |
|
12 | + public function setEntityAttributes(array $attributes); |
|
13 | 13 | |
14 | - /** |
|
15 | - * Get the raw object's values. |
|
16 | - * |
|
17 | - * @return array |
|
18 | - */ |
|
19 | - public function getEntityAttributes(); |
|
14 | + /** |
|
15 | + * Get the raw object's values. |
|
16 | + * |
|
17 | + * @return array |
|
18 | + */ |
|
19 | + public function getEntityAttributes(); |
|
20 | 20 | } |
@@ -17,114 +17,114 @@ |
||
17 | 17 | */ |
18 | 18 | class Analogue |
19 | 19 | { |
20 | - /** |
|
21 | - * @var self |
|
22 | - */ |
|
23 | - protected static $instance; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var Manager |
|
27 | - */ |
|
28 | - protected static $manager; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Capsule |
|
32 | - */ |
|
33 | - protected static $capsule; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
38 | - protected static $booted = false; |
|
39 | - |
|
40 | - /** |
|
41 | - * Analogue constructor. |
|
42 | - * @param array $connection |
|
43 | - */ |
|
44 | - public function __construct(array $connection) |
|
45 | - { |
|
46 | - if (!static::$booted) { |
|
47 | - static::$capsule = new Capsule; |
|
48 | - |
|
49 | - $this->addConnection($connection); |
|
50 | - |
|
51 | - $this->boot(); |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Boot Analogue |
|
57 | - * |
|
58 | - * @return Analogue |
|
59 | - */ |
|
60 | - public function boot() |
|
61 | - { |
|
62 | - if (static::$booted) { |
|
63 | - return $this; |
|
64 | - } |
|
65 | - |
|
66 | - $dispatcher = new Dispatcher; |
|
67 | - |
|
68 | - $connectionProvider = new CapsuleConnectionProvider(static::$capsule); |
|
69 | - |
|
70 | - $illuminate = new IlluminateDriver($connectionProvider); |
|
71 | - |
|
72 | - $driverManager = new DriverManager; |
|
73 | - |
|
74 | - $driverManager->addDriver($illuminate); |
|
75 | - |
|
76 | - static::$manager = new Manager($driverManager, $dispatcher); |
|
20 | + /** |
|
21 | + * @var self |
|
22 | + */ |
|
23 | + protected static $instance; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var Manager |
|
27 | + */ |
|
28 | + protected static $manager; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Capsule |
|
32 | + */ |
|
33 | + protected static $capsule; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | + protected static $booted = false; |
|
39 | + |
|
40 | + /** |
|
41 | + * Analogue constructor. |
|
42 | + * @param array $connection |
|
43 | + */ |
|
44 | + public function __construct(array $connection) |
|
45 | + { |
|
46 | + if (!static::$booted) { |
|
47 | + static::$capsule = new Capsule; |
|
48 | + |
|
49 | + $this->addConnection($connection); |
|
50 | + |
|
51 | + $this->boot(); |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Boot Analogue |
|
57 | + * |
|
58 | + * @return Analogue |
|
59 | + */ |
|
60 | + public function boot() |
|
61 | + { |
|
62 | + if (static::$booted) { |
|
63 | + return $this; |
|
64 | + } |
|
65 | + |
|
66 | + $dispatcher = new Dispatcher; |
|
67 | + |
|
68 | + $connectionProvider = new CapsuleConnectionProvider(static::$capsule); |
|
69 | + |
|
70 | + $illuminate = new IlluminateDriver($connectionProvider); |
|
71 | + |
|
72 | + $driverManager = new DriverManager; |
|
73 | + |
|
74 | + $driverManager->addDriver($illuminate); |
|
75 | + |
|
76 | + static::$manager = new Manager($driverManager, $dispatcher); |
|
77 | 77 | |
78 | - static::$instance = $this; |
|
79 | - |
|
80 | - static::$booted = true; |
|
81 | - |
|
82 | - return $this; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Add a connection array to Capsule |
|
87 | - * |
|
88 | - * @param array $config |
|
89 | - * @param string $name |
|
90 | - */ |
|
91 | - public function addConnection($config, $name = 'default') |
|
92 | - { |
|
93 | - static::$capsule->addConnection($config, $name); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get a Database connection object |
|
98 | - * |
|
99 | - * @param $name |
|
100 | - * @return \Illuminate\Database\Connection |
|
101 | - */ |
|
102 | - public function connection($name = null) |
|
103 | - { |
|
104 | - return static::$capsule->getConnection($name); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Dynamically handle static calls to the instance, Facade Style. |
|
109 | - * |
|
110 | - * @param string $method |
|
111 | - * @param array $parameters |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public static function __callStatic($method, $parameters) |
|
115 | - { |
|
116 | - return call_user_func_array([static::$instance, $method], $parameters); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Dynamically handle calls to the Analogue Manager instance. |
|
121 | - * |
|
122 | - * @param string $method |
|
123 | - * @param array $parameters |
|
124 | - * @return mixed |
|
125 | - */ |
|
126 | - public function __call($method, $parameters) |
|
127 | - { |
|
128 | - return call_user_func_array([static::$manager, $method], $parameters); |
|
129 | - } |
|
78 | + static::$instance = $this; |
|
79 | + |
|
80 | + static::$booted = true; |
|
81 | + |
|
82 | + return $this; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Add a connection array to Capsule |
|
87 | + * |
|
88 | + * @param array $config |
|
89 | + * @param string $name |
|
90 | + */ |
|
91 | + public function addConnection($config, $name = 'default') |
|
92 | + { |
|
93 | + static::$capsule->addConnection($config, $name); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get a Database connection object |
|
98 | + * |
|
99 | + * @param $name |
|
100 | + * @return \Illuminate\Database\Connection |
|
101 | + */ |
|
102 | + public function connection($name = null) |
|
103 | + { |
|
104 | + return static::$capsule->getConnection($name); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Dynamically handle static calls to the instance, Facade Style. |
|
109 | + * |
|
110 | + * @param string $method |
|
111 | + * @param array $parameters |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public static function __callStatic($method, $parameters) |
|
115 | + { |
|
116 | + return call_user_func_array([static::$instance, $method], $parameters); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Dynamically handle calls to the Analogue Manager instance. |
|
121 | + * |
|
122 | + * @param string $method |
|
123 | + * @param array $parameters |
|
124 | + * @return mixed |
|
125 | + */ |
|
126 | + public function __call($method, $parameters) |
|
127 | + { |
|
128 | + return call_user_func_array([static::$manager, $method], $parameters); |
|
129 | + } |
|
130 | 130 | } |
@@ -10,387 +10,387 @@ |
||
10 | 10 | |
11 | 11 | class EntityCollection extends Collection |
12 | 12 | { |
13 | - /** |
|
14 | - * Wrapper Factory |
|
15 | - * |
|
16 | - * @var \Analogue\ORM\System\Wrappers\Factory |
|
17 | - */ |
|
18 | - protected $factory; |
|
19 | - |
|
20 | - /** |
|
21 | - * EntityCollection constructor. |
|
22 | - * @param array|null $entities |
|
23 | - */ |
|
24 | - public function __construct(array $entities = null) |
|
25 | - { |
|
26 | - $this->factory = new Factory; |
|
27 | - |
|
28 | - parent::__construct($entities); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Find an entity in the collection by key. |
|
33 | - * |
|
34 | - * @param mixed $key |
|
35 | - * @param mixed $default |
|
36 | - * @throws MappingException |
|
37 | - * @return \Analogue\ORM\Entity |
|
38 | - */ |
|
39 | - public function find($key, $default = null) |
|
40 | - { |
|
41 | - if ($key instanceof Mappable) { |
|
42 | - $key = $this->getEntityKey($key); |
|
43 | - } |
|
44 | - |
|
45 | - return array_first($this->items, function ($itemKey, $entity) use ($key) { |
|
46 | - return $this->getEntityKey($entity) == $key; |
|
47 | - }, $default); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Add an entity to the collection. |
|
52 | - * |
|
53 | - * @param Mappable $entity |
|
54 | - * @return $this |
|
55 | - */ |
|
56 | - public function add($entity) |
|
57 | - { |
|
58 | - $this->push($entity); |
|
59 | - |
|
60 | - return $this; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Remove an entity from the collection |
|
65 | - * |
|
66 | - * @param $entity |
|
67 | - * @throws MappingException |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - public function remove($entity) |
|
71 | - { |
|
72 | - $key = $this->getEntityKey($entity); |
|
73 | - |
|
74 | - return $this->pull($key); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Push an item onto the end of the collection. |
|
79 | - * |
|
80 | - * @param mixed $value |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function push($value) |
|
84 | - { |
|
85 | - $this->offsetSet(null, $value); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Put an item in the collection by key. |
|
90 | - * |
|
91 | - * @param mixed $key |
|
92 | - * @param mixed $value |
|
93 | - * @return void |
|
94 | - */ |
|
95 | - public function put($key, $value) |
|
96 | - { |
|
97 | - $this->offsetSet($key, $value); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Set the item at a given offset. |
|
102 | - * |
|
103 | - * @param mixed $key |
|
104 | - * @param mixed $value |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function offsetSet($key, $value) |
|
108 | - { |
|
109 | - if (is_null($key)) { |
|
110 | - $this->items[] = $value; |
|
111 | - } else { |
|
112 | - $this->items[$key] = $value; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Determine if a key exists in the collection. |
|
118 | - * |
|
119 | - * @param mixed $key |
|
120 | - * @param mixed|null $value |
|
121 | - * @return bool |
|
122 | - */ |
|
123 | - public function contains($key, $value = null) |
|
124 | - { |
|
125 | - return !is_null($this->find($key)); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Fetch a nested element of the collection. |
|
130 | - * |
|
131 | - * @param string $key |
|
132 | - * @return self |
|
133 | - */ |
|
134 | - public function fetch($key) |
|
135 | - { |
|
136 | - return new static(array_fetch($this->toArray(), $key)); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Generic function for returning class.key value pairs |
|
141 | - * |
|
142 | - * @throws MappingException |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function getEntityHashes() |
|
146 | - { |
|
147 | - return array_map(function($entity) { |
|
148 | - $class = get_class($entity); |
|
149 | - |
|
150 | - $mapper = Manager::getMapper($class); |
|
13 | + /** |
|
14 | + * Wrapper Factory |
|
15 | + * |
|
16 | + * @var \Analogue\ORM\System\Wrappers\Factory |
|
17 | + */ |
|
18 | + protected $factory; |
|
19 | + |
|
20 | + /** |
|
21 | + * EntityCollection constructor. |
|
22 | + * @param array|null $entities |
|
23 | + */ |
|
24 | + public function __construct(array $entities = null) |
|
25 | + { |
|
26 | + $this->factory = new Factory; |
|
27 | + |
|
28 | + parent::__construct($entities); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Find an entity in the collection by key. |
|
33 | + * |
|
34 | + * @param mixed $key |
|
35 | + * @param mixed $default |
|
36 | + * @throws MappingException |
|
37 | + * @return \Analogue\ORM\Entity |
|
38 | + */ |
|
39 | + public function find($key, $default = null) |
|
40 | + { |
|
41 | + if ($key instanceof Mappable) { |
|
42 | + $key = $this->getEntityKey($key); |
|
43 | + } |
|
44 | + |
|
45 | + return array_first($this->items, function ($itemKey, $entity) use ($key) { |
|
46 | + return $this->getEntityKey($entity) == $key; |
|
47 | + }, $default); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Add an entity to the collection. |
|
52 | + * |
|
53 | + * @param Mappable $entity |
|
54 | + * @return $this |
|
55 | + */ |
|
56 | + public function add($entity) |
|
57 | + { |
|
58 | + $this->push($entity); |
|
59 | + |
|
60 | + return $this; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Remove an entity from the collection |
|
65 | + * |
|
66 | + * @param $entity |
|
67 | + * @throws MappingException |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + public function remove($entity) |
|
71 | + { |
|
72 | + $key = $this->getEntityKey($entity); |
|
73 | + |
|
74 | + return $this->pull($key); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Push an item onto the end of the collection. |
|
79 | + * |
|
80 | + * @param mixed $value |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function push($value) |
|
84 | + { |
|
85 | + $this->offsetSet(null, $value); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Put an item in the collection by key. |
|
90 | + * |
|
91 | + * @param mixed $key |
|
92 | + * @param mixed $value |
|
93 | + * @return void |
|
94 | + */ |
|
95 | + public function put($key, $value) |
|
96 | + { |
|
97 | + $this->offsetSet($key, $value); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Set the item at a given offset. |
|
102 | + * |
|
103 | + * @param mixed $key |
|
104 | + * @param mixed $value |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function offsetSet($key, $value) |
|
108 | + { |
|
109 | + if (is_null($key)) { |
|
110 | + $this->items[] = $value; |
|
111 | + } else { |
|
112 | + $this->items[$key] = $value; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Determine if a key exists in the collection. |
|
118 | + * |
|
119 | + * @param mixed $key |
|
120 | + * @param mixed|null $value |
|
121 | + * @return bool |
|
122 | + */ |
|
123 | + public function contains($key, $value = null) |
|
124 | + { |
|
125 | + return !is_null($this->find($key)); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Fetch a nested element of the collection. |
|
130 | + * |
|
131 | + * @param string $key |
|
132 | + * @return self |
|
133 | + */ |
|
134 | + public function fetch($key) |
|
135 | + { |
|
136 | + return new static(array_fetch($this->toArray(), $key)); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Generic function for returning class.key value pairs |
|
141 | + * |
|
142 | + * @throws MappingException |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function getEntityHashes() |
|
146 | + { |
|
147 | + return array_map(function($entity) { |
|
148 | + $class = get_class($entity); |
|
149 | + |
|
150 | + $mapper = Manager::getMapper($class); |
|
151 | 151 | |
152 | - $keyName = $mapper->getEntityMap()->getKeyName(); |
|
152 | + $keyName = $mapper->getEntityMap()->getKeyName(); |
|
153 | 153 | |
154 | - return $class . '.' . $entity->getEntityAttribute($keyName); |
|
155 | - }, |
|
156 | - $this->items); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Get a subset of the collection from entity hashes |
|
161 | - * |
|
162 | - * @param array $hashes |
|
163 | - * @throws MappingException |
|
164 | - * @return array |
|
165 | - */ |
|
166 | - public function getSubsetByHashes(array $hashes) |
|
167 | - { |
|
168 | - $subset = []; |
|
169 | - |
|
170 | - foreach ($this->items as $item) { |
|
171 | - $class = get_class($item); |
|
172 | - |
|
173 | - $mapper = Manager::getMapper($class); |
|
154 | + return $class . '.' . $entity->getEntityAttribute($keyName); |
|
155 | + }, |
|
156 | + $this->items); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Get a subset of the collection from entity hashes |
|
161 | + * |
|
162 | + * @param array $hashes |
|
163 | + * @throws MappingException |
|
164 | + * @return array |
|
165 | + */ |
|
166 | + public function getSubsetByHashes(array $hashes) |
|
167 | + { |
|
168 | + $subset = []; |
|
169 | + |
|
170 | + foreach ($this->items as $item) { |
|
171 | + $class = get_class($item); |
|
172 | + |
|
173 | + $mapper = Manager::getMapper($class); |
|
174 | 174 | |
175 | - $keyName = $mapper->getEntityMap()->getKeyName(); |
|
176 | - |
|
177 | - if (in_array($class . '.' . $item->$keyName, $hashes)) { |
|
178 | - $subset[] = $item; |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - return $subset; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Merge the collection with the given items. |
|
187 | - * |
|
188 | - * @param array $items |
|
189 | - * @throws MappingException |
|
190 | - * @return self |
|
191 | - */ |
|
192 | - public function merge($items) |
|
193 | - { |
|
194 | - $dictionary = $this->getDictionary(); |
|
195 | - |
|
196 | - foreach ($items as $item) { |
|
197 | - $dictionary[$this->getEntityKey($item)] = $item; |
|
198 | - } |
|
199 | - |
|
200 | - return new static(array_values($dictionary)); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Diff the collection with the given items. |
|
205 | - * |
|
206 | - * @param \ArrayAccess|array $items |
|
207 | - * @return self |
|
208 | - */ |
|
209 | - public function diff($items) |
|
210 | - { |
|
211 | - $diff = new static; |
|
212 | - |
|
213 | - $dictionary = $this->getDictionary($items); |
|
214 | - |
|
215 | - foreach ($this->items as $item) { |
|
216 | - if (!isset($dictionary[$this->getEntityKey($item)])) { |
|
217 | - $diff->add($item); |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - return $diff; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * Intersect the collection with the given items. |
|
226 | - * |
|
227 | - * @param \ArrayAccess|array $items |
|
228 | - * @throws MappingException |
|
229 | - * @return self |
|
230 | - */ |
|
231 | - public function intersect($items) |
|
232 | - { |
|
233 | - $intersect = new static; |
|
234 | - |
|
235 | - $dictionary = $this->getDictionary($items); |
|
236 | - |
|
237 | - foreach ($this->items as $item) { |
|
238 | - if (isset($dictionary[$this->getEntityKey($item)])) { |
|
239 | - $intersect->add($item); |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - return $intersect; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Returns only the models from the collection with the specified keys. |
|
248 | - * |
|
249 | - * @param mixed $keys |
|
250 | - * @return self |
|
251 | - */ |
|
252 | - public function only($keys) |
|
253 | - { |
|
254 | - $dictionary = array_only($this->getDictionary(), $keys); |
|
255 | - |
|
256 | - return new static(array_values($dictionary)); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Returns all models in the collection except the models with specified keys. |
|
261 | - * |
|
262 | - * @param mixed $keys |
|
263 | - * @return self |
|
264 | - */ |
|
265 | - public function except($keys) |
|
266 | - { |
|
267 | - $dictionary = array_except($this->getDictionary(), $keys); |
|
268 | - |
|
269 | - return new static(array_values($dictionary)); |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Get a dictionary keyed by primary keys. |
|
274 | - * |
|
275 | - * @param \ArrayAccess|array $items |
|
276 | - * @throws MappingException |
|
277 | - * @return array |
|
278 | - */ |
|
279 | - public function getDictionary($items = null) |
|
280 | - { |
|
281 | - $items = is_null($items) ? $this->items : $items; |
|
282 | - |
|
283 | - $dictionary = []; |
|
284 | - |
|
285 | - foreach ($items as $value) { |
|
286 | - $dictionary[$this->getEntityKey($value)] = $value; |
|
287 | - } |
|
288 | - |
|
289 | - return $dictionary; |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * @throws MappingException |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public function getEntityKeys() |
|
297 | - { |
|
298 | - return array_keys($this->getDictionary()); |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * @param $entity |
|
303 | - * @throws MappingException |
|
304 | - * @return mixed |
|
305 | - */ |
|
306 | - protected function getEntityKey($entity) |
|
307 | - { |
|
308 | - $keyName = Manager::getMapper($entity)->getEntityMap()->getKeyName(); |
|
175 | + $keyName = $mapper->getEntityMap()->getKeyName(); |
|
176 | + |
|
177 | + if (in_array($class . '.' . $item->$keyName, $hashes)) { |
|
178 | + $subset[] = $item; |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + return $subset; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Merge the collection with the given items. |
|
187 | + * |
|
188 | + * @param array $items |
|
189 | + * @throws MappingException |
|
190 | + * @return self |
|
191 | + */ |
|
192 | + public function merge($items) |
|
193 | + { |
|
194 | + $dictionary = $this->getDictionary(); |
|
195 | + |
|
196 | + foreach ($items as $item) { |
|
197 | + $dictionary[$this->getEntityKey($item)] = $item; |
|
198 | + } |
|
199 | + |
|
200 | + return new static(array_values($dictionary)); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Diff the collection with the given items. |
|
205 | + * |
|
206 | + * @param \ArrayAccess|array $items |
|
207 | + * @return self |
|
208 | + */ |
|
209 | + public function diff($items) |
|
210 | + { |
|
211 | + $diff = new static; |
|
212 | + |
|
213 | + $dictionary = $this->getDictionary($items); |
|
214 | + |
|
215 | + foreach ($this->items as $item) { |
|
216 | + if (!isset($dictionary[$this->getEntityKey($item)])) { |
|
217 | + $diff->add($item); |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + return $diff; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * Intersect the collection with the given items. |
|
226 | + * |
|
227 | + * @param \ArrayAccess|array $items |
|
228 | + * @throws MappingException |
|
229 | + * @return self |
|
230 | + */ |
|
231 | + public function intersect($items) |
|
232 | + { |
|
233 | + $intersect = new static; |
|
234 | + |
|
235 | + $dictionary = $this->getDictionary($items); |
|
236 | + |
|
237 | + foreach ($this->items as $item) { |
|
238 | + if (isset($dictionary[$this->getEntityKey($item)])) { |
|
239 | + $intersect->add($item); |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + return $intersect; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Returns only the models from the collection with the specified keys. |
|
248 | + * |
|
249 | + * @param mixed $keys |
|
250 | + * @return self |
|
251 | + */ |
|
252 | + public function only($keys) |
|
253 | + { |
|
254 | + $dictionary = array_only($this->getDictionary(), $keys); |
|
255 | + |
|
256 | + return new static(array_values($dictionary)); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Returns all models in the collection except the models with specified keys. |
|
261 | + * |
|
262 | + * @param mixed $keys |
|
263 | + * @return self |
|
264 | + */ |
|
265 | + public function except($keys) |
|
266 | + { |
|
267 | + $dictionary = array_except($this->getDictionary(), $keys); |
|
268 | + |
|
269 | + return new static(array_values($dictionary)); |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Get a dictionary keyed by primary keys. |
|
274 | + * |
|
275 | + * @param \ArrayAccess|array $items |
|
276 | + * @throws MappingException |
|
277 | + * @return array |
|
278 | + */ |
|
279 | + public function getDictionary($items = null) |
|
280 | + { |
|
281 | + $items = is_null($items) ? $this->items : $items; |
|
282 | + |
|
283 | + $dictionary = []; |
|
284 | + |
|
285 | + foreach ($items as $value) { |
|
286 | + $dictionary[$this->getEntityKey($value)] = $value; |
|
287 | + } |
|
288 | + |
|
289 | + return $dictionary; |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * @throws MappingException |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public function getEntityKeys() |
|
297 | + { |
|
298 | + return array_keys($this->getDictionary()); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * @param $entity |
|
303 | + * @throws MappingException |
|
304 | + * @return mixed |
|
305 | + */ |
|
306 | + protected function getEntityKey($entity) |
|
307 | + { |
|
308 | + $keyName = Manager::getMapper($entity)->getEntityMap()->getKeyName(); |
|
309 | 309 | |
310 | - $wrapper = $this->factory->make($entity); |
|
311 | - |
|
312 | - return $wrapper->getEntityAttribute($keyName); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Get the max value of a given key. |
|
317 | - * |
|
318 | - * @param string|null $key |
|
319 | - * @throws MappingException |
|
320 | - * @return mixed |
|
321 | - */ |
|
322 | - public function max($key = null) |
|
323 | - { |
|
324 | - return $this->reduce(function($result, $item) use ($key) { |
|
325 | - $wrapper = $this->factory->make($item); |
|
326 | - |
|
327 | - return (is_null($result) || $wrapper->getEntityAttribute($key) > $result) ? |
|
328 | - $wrapper->getEntityAttribute($key) : $result; |
|
329 | - }); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * Get the min value of a given key. |
|
334 | - * |
|
335 | - * @param string|null $key |
|
336 | - * @throws MappingException |
|
337 | - * @return mixed |
|
338 | - */ |
|
339 | - public function min($key = null) |
|
340 | - { |
|
341 | - return $this->reduce(function($result, $item) use ($key) { |
|
342 | - $wrapper = $this->factory->make($item); |
|
343 | - |
|
344 | - return (is_null($result) || $wrapper->getEntityAttribute($key) < $result) |
|
345 | - ? $wrapper->getEntityAttribute($key) : $result; |
|
346 | - }); |
|
347 | - } |
|
348 | - |
|
349 | - /** |
|
350 | - * Get an array with the values of a given key. |
|
351 | - * |
|
352 | - * @param string $value |
|
353 | - * @param string|null $key |
|
354 | - * @return self |
|
355 | - */ |
|
356 | - public function pluck($value, $key = null) |
|
357 | - { |
|
358 | - return new Collection(Arr::pluck($this->items, $value, $key)); |
|
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Alias for the "pluck" method. |
|
363 | - * |
|
364 | - * @param string $value |
|
365 | - * @param string|null $key |
|
366 | - * @return self |
|
367 | - */ |
|
368 | - public function lists($value, $key = null) |
|
369 | - { |
|
370 | - return $this->pluck($value, $key); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Return only unique items from the collection. |
|
375 | - * |
|
376 | - * @param string|null $key |
|
377 | - * @throws MappingException |
|
378 | - * @return self |
|
379 | - */ |
|
380 | - public function unique($key = null) |
|
381 | - { |
|
382 | - $dictionary = $this->getDictionary(); |
|
383 | - |
|
384 | - return new static(array_values($dictionary)); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Get a base Support collection instance from this collection. |
|
389 | - * |
|
390 | - * @return \Illuminate\Support\Collection |
|
391 | - */ |
|
392 | - public function toBase() |
|
393 | - { |
|
394 | - return new Collection($this->items); |
|
395 | - } |
|
310 | + $wrapper = $this->factory->make($entity); |
|
311 | + |
|
312 | + return $wrapper->getEntityAttribute($keyName); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Get the max value of a given key. |
|
317 | + * |
|
318 | + * @param string|null $key |
|
319 | + * @throws MappingException |
|
320 | + * @return mixed |
|
321 | + */ |
|
322 | + public function max($key = null) |
|
323 | + { |
|
324 | + return $this->reduce(function($result, $item) use ($key) { |
|
325 | + $wrapper = $this->factory->make($item); |
|
326 | + |
|
327 | + return (is_null($result) || $wrapper->getEntityAttribute($key) > $result) ? |
|
328 | + $wrapper->getEntityAttribute($key) : $result; |
|
329 | + }); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * Get the min value of a given key. |
|
334 | + * |
|
335 | + * @param string|null $key |
|
336 | + * @throws MappingException |
|
337 | + * @return mixed |
|
338 | + */ |
|
339 | + public function min($key = null) |
|
340 | + { |
|
341 | + return $this->reduce(function($result, $item) use ($key) { |
|
342 | + $wrapper = $this->factory->make($item); |
|
343 | + |
|
344 | + return (is_null($result) || $wrapper->getEntityAttribute($key) < $result) |
|
345 | + ? $wrapper->getEntityAttribute($key) : $result; |
|
346 | + }); |
|
347 | + } |
|
348 | + |
|
349 | + /** |
|
350 | + * Get an array with the values of a given key. |
|
351 | + * |
|
352 | + * @param string $value |
|
353 | + * @param string|null $key |
|
354 | + * @return self |
|
355 | + */ |
|
356 | + public function pluck($value, $key = null) |
|
357 | + { |
|
358 | + return new Collection(Arr::pluck($this->items, $value, $key)); |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Alias for the "pluck" method. |
|
363 | + * |
|
364 | + * @param string $value |
|
365 | + * @param string|null $key |
|
366 | + * @return self |
|
367 | + */ |
|
368 | + public function lists($value, $key = null) |
|
369 | + { |
|
370 | + return $this->pluck($value, $key); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Return only unique items from the collection. |
|
375 | + * |
|
376 | + * @param string|null $key |
|
377 | + * @throws MappingException |
|
378 | + * @return self |
|
379 | + */ |
|
380 | + public function unique($key = null) |
|
381 | + { |
|
382 | + $dictionary = $this->getDictionary(); |
|
383 | + |
|
384 | + return new static(array_values($dictionary)); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Get a base Support collection instance from this collection. |
|
389 | + * |
|
390 | + * @return \Illuminate\Support\Collection |
|
391 | + */ |
|
392 | + public function toBase() |
|
393 | + { |
|
394 | + return new Collection($this->items); |
|
395 | + } |
|
396 | 396 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $key = $this->getEntityKey($key); |
43 | 43 | } |
44 | 44 | |
45 | - return array_first($this->items, function ($itemKey, $entity) use ($key) { |
|
45 | + return array_first($this->items, function($itemKey, $entity) use ($key) { |
|
46 | 46 | return $this->getEntityKey($entity) == $key; |
47 | 47 | }, $default); |
48 | 48 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $keyName = $mapper->getEntityMap()->getKeyName(); |
153 | 153 | |
154 | - return $class . '.' . $entity->getEntityAttribute($keyName); |
|
154 | + return $class.'.'.$entity->getEntityAttribute($keyName); |
|
155 | 155 | }, |
156 | 156 | $this->items); |
157 | 157 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | $keyName = $mapper->getEntityMap()->getKeyName(); |
176 | 176 | |
177 | - if (in_array($class . '.' . $item->$keyName, $hashes)) { |
|
177 | + if (in_array($class.'.'.$item->$keyName, $hashes)) { |
|
178 | 178 | $subset[] = $item; |
179 | 179 | } |
180 | 180 | } |