Completed
Push — 5.1 ( eacfab...af1a7b )
by Rémi
9s
created
src/Commands/Delete.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,38 +6,38 @@
 block discarded – undo
6 6
 
7 7
 class Delete extends Command
8 8
 {
9
-    /**
10
-     * Execute the Delete Statement
11
-     *
12
-     * @throws MappingException
13
-     * @throws \InvalidArgumentException
14
-     * @return false|void
15
-     */
16
-    public function execute()
17
-    {
18
-        $aggregate = $this->aggregate;
19
-
20
-        $entity = $aggregate->getEntityObject();
21
-
22
-        $mapper = $aggregate->getMapper();
23
-
24
-        if ($mapper->fireEvent('deleting', $entity) === false) {
25
-            return false;
26
-        }
27
-
28
-        $keyName = $aggregate->getEntityMap()->getKeyName();
9
+	/**
10
+	 * Execute the Delete Statement
11
+	 *
12
+	 * @throws MappingException
13
+	 * @throws \InvalidArgumentException
14
+	 * @return false|void
15
+	 */
16
+	public function execute()
17
+	{
18
+		$aggregate = $this->aggregate;
19
+
20
+		$entity = $aggregate->getEntityObject();
21
+
22
+		$mapper = $aggregate->getMapper();
23
+
24
+		if ($mapper->fireEvent('deleting', $entity) === false) {
25
+			return false;
26
+		}
27
+
28
+		$keyName = $aggregate->getEntityMap()->getKeyName();
29 29
         
30
-        $id = $this->aggregate->getEntityId();
30
+		$id = $this->aggregate->getEntityId();
31 31
 
32
-        if (is_null($id)) {
33
-            throw new MappingException('Executed a delete command on an entity with "null" as primary key');
34
-        }
32
+		if (is_null($id)) {
33
+			throw new MappingException('Executed a delete command on an entity with "null" as primary key');
34
+		}
35 35
 
36
-        $this->query->where($keyName, '=', $id)->delete();
36
+		$this->query->where($keyName, '=', $id)->delete();
37 37
 
38
-        $mapper->fireEvent('deleted', $entity, false);
38
+		$mapper->fireEvent('deleted', $entity, false);
39 39
 
40
-        // Once the Entity is successfully deleted, we'll just set the primary key to null.
41
-        $aggregate->setEntityAttribute($keyName, null);
42
-    }
40
+		// Once the Entity is successfully deleted, we'll just set the primary key to null.
41
+		$aggregate->setEntityAttribute($keyName, null);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
src/Commands/Command.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,31 +7,31 @@
 block discarded – undo
7 7
 
8 8
 abstract class Command
9 9
 {
10
-    /**
11
-     * The aggregated entity on which the command is executed
12
-     *
13
-     * @var \Analogue\ORM\System\Aggregate
14
-     */
15
-    protected $aggregate;
10
+	/**
11
+	 * The aggregated entity on which the command is executed
12
+	 *
13
+	 * @var \Analogue\ORM\System\Aggregate
14
+	 */
15
+	protected $aggregate;
16 16
 
17
-    /**
18
-     * Query Builder instance
19
-     *
20
-     * @var \Illuminate\Database\Query\Builder
21
-     */
22
-    protected $query;
17
+	/**
18
+	 * Query Builder instance
19
+	 *
20
+	 * @var \Illuminate\Database\Query\Builder
21
+	 */
22
+	protected $query;
23 23
 
24
-    /**
25
-     * Command constructor.
26
-     * @param Aggregate $aggregate
27
-     * @param QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter $query
28
-     */
29
-    public function __construct(Aggregate $aggregate, QueryAdapter $query)
30
-    {
31
-        $this->aggregate = $aggregate;
24
+	/**
25
+	 * Command constructor.
26
+	 * @param Aggregate $aggregate
27
+	 * @param QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter $query
28
+	 */
29
+	public function __construct(Aggregate $aggregate, QueryAdapter $query)
30
+	{
31
+		$this->aggregate = $aggregate;
32 32
 
33
-        $this->query = $query->from($aggregate->getEntityMap()->getTable());
34
-    }
33
+		$this->query = $query->from($aggregate->getEntityMap()->getTable());
34
+	}
35 35
 
36
-    abstract public function execute();
36
+	abstract public function execute();
37 37
 }
Please login to merge, or discard this patch.
src/ValueObject.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -11,158 +11,158 @@
 block discarded – undo
11 11
 
12 12
 class ValueObject implements Mappable, ArrayAccess, Jsonable, JsonSerializable, Arrayable
13 13
 {
14
-    use MappableTrait;
15
-
16
-    /**
17
-     * Dynamically retrieve attributes on the entity.
18
-     *
19
-     * @param  string $key
20
-     * @return mixed
21
-     */
22
-    public function __get($key)
23
-    {
24
-        return $this->attributes[$key];
25
-    }
26
-
27
-    /**
28
-     * Dynamically set attributes on the entity.
29
-     *
30
-     * @param  string $key
31
-     * @param  mixed  $value
32
-     * @return void
33
-     */
34
-    public function __set($key, $value)
35
-    {
36
-        $this->attributes[$key] = $value;
37
-    }
38
-
39
-    /**
40
-     * Determine if an attribute exists on the entity.
41
-     *
42
-     * @param  string $key
43
-     * @return bool
44
-     */
45
-    public function __isset($key)
46
-    {
47
-        return array_key_exists($key, $this->attributes);
48
-    }
49
-
50
-    /**
51
-     * Unset an attribute on the entity.
52
-     *
53
-     * @param  string $key
54
-     * @return void
55
-     */
56
-    public function __unset($key)
57
-    {
58
-        unset($this->attributes[$key]);
59
-    }
14
+	use MappableTrait;
15
+
16
+	/**
17
+	 * Dynamically retrieve attributes on the entity.
18
+	 *
19
+	 * @param  string $key
20
+	 * @return mixed
21
+	 */
22
+	public function __get($key)
23
+	{
24
+		return $this->attributes[$key];
25
+	}
26
+
27
+	/**
28
+	 * Dynamically set attributes on the entity.
29
+	 *
30
+	 * @param  string $key
31
+	 * @param  mixed  $value
32
+	 * @return void
33
+	 */
34
+	public function __set($key, $value)
35
+	{
36
+		$this->attributes[$key] = $value;
37
+	}
38
+
39
+	/**
40
+	 * Determine if an attribute exists on the entity.
41
+	 *
42
+	 * @param  string $key
43
+	 * @return bool
44
+	 */
45
+	public function __isset($key)
46
+	{
47
+		return array_key_exists($key, $this->attributes);
48
+	}
49
+
50
+	/**
51
+	 * Unset an attribute on the entity.
52
+	 *
53
+	 * @param  string $key
54
+	 * @return void
55
+	 */
56
+	public function __unset($key)
57
+	{
58
+		unset($this->attributes[$key]);
59
+	}
60 60
 
61 61
     
62
-    /**
63
-     * Determine if the given attribute exists.
64
-     *
65
-     * @param  mixed $offset
66
-     * @return bool
67
-     */
68
-    public function offsetExists($offset)
69
-    {
70
-        return isset($this->$offset);
71
-    }
72
-
73
-    /**
74
-     * Get the value for a given offset.
75
-     *
76
-     * @param  mixed $offset
77
-     * @return mixed
78
-     */
79
-    public function offsetGet($offset)
80
-    {
81
-        return $this->$offset;
82
-    }
83
-
84
-    /**
85
-     * Set the value for a given offset.
86
-     *
87
-     * @param  mixed $offset
88
-     * @param  mixed $value
89
-     * @return void
90
-     */
91
-    public function offsetSet($offset, $value)
92
-    {
93
-        $this->$offset = $value;
94
-    }
95
-
96
-    /**
97
-     * Unset the value for a given offset.
98
-     *
99
-     * @param  mixed $offset
100
-     * @return void
101
-     */
102
-    public function offsetUnset($offset)
103
-    {
104
-        unset($this->$offset);
105
-    }
106
-
107
-    /**
108
-     * Convert the object into something JSON serializable.
109
-     *
110
-     * @return array
111
-     */
112
-    public function jsonSerialize()
113
-    {
114
-        return $this->toArray();
115
-    }
116
-
117
-    /**
118
-     * Convert the entity instance to JSON.
119
-     *
120
-     * @param  int $options
121
-     * @return string
122
-     */
123
-    public function toJson($options = 0)
124
-    {
125
-        return json_encode($this->toArray(), $options);
126
-    }
127
-
128
-    /**
129
-     * Convert Mappable object to array;
130
-     *
131
-     * @return array
132
-     */
133
-    public function toArray()
134
-    {
135
-        return $this->attributesToArray($this->attributes);
136
-    }
137
-
138
-    /**
139
-     * Transform the Object to array/json,
140
-     *
141
-     * @param  array $sourceAttributes
142
-     * @return array
143
-     */
144
-    protected function attributesToArray(array $sourceAttributes)
145
-    {
146
-        $attributes = [];
147
-
148
-        foreach ($sourceAttributes as $key => $attribute) {
149
-            // If the attribute is a proxy, and hasn't be loaded, we discard
150
-            // it from the returned set.
151
-            if ($attribute instanceof ProxyInterface && !$attribute->isLoaded()) {
152
-                continue;
153
-            }
154
-
155
-            if ($attribute instanceof Carbon) {
156
-                $attributes[$key] = $attribute->__toString();
157
-                continue;
158
-            }
159
-
160
-            if ($attribute instanceof Arrayable) {
161
-                $attributes[$key] = $attribute->toArray();
162
-            } else {
163
-                $attributes[$key] = $attribute;
164
-            }
165
-        }
166
-        return $attributes;
167
-    }
62
+	/**
63
+	 * Determine if the given attribute exists.
64
+	 *
65
+	 * @param  mixed $offset
66
+	 * @return bool
67
+	 */
68
+	public function offsetExists($offset)
69
+	{
70
+		return isset($this->$offset);
71
+	}
72
+
73
+	/**
74
+	 * Get the value for a given offset.
75
+	 *
76
+	 * @param  mixed $offset
77
+	 * @return mixed
78
+	 */
79
+	public function offsetGet($offset)
80
+	{
81
+		return $this->$offset;
82
+	}
83
+
84
+	/**
85
+	 * Set the value for a given offset.
86
+	 *
87
+	 * @param  mixed $offset
88
+	 * @param  mixed $value
89
+	 * @return void
90
+	 */
91
+	public function offsetSet($offset, $value)
92
+	{
93
+		$this->$offset = $value;
94
+	}
95
+
96
+	/**
97
+	 * Unset the value for a given offset.
98
+	 *
99
+	 * @param  mixed $offset
100
+	 * @return void
101
+	 */
102
+	public function offsetUnset($offset)
103
+	{
104
+		unset($this->$offset);
105
+	}
106
+
107
+	/**
108
+	 * Convert the object into something JSON serializable.
109
+	 *
110
+	 * @return array
111
+	 */
112
+	public function jsonSerialize()
113
+	{
114
+		return $this->toArray();
115
+	}
116
+
117
+	/**
118
+	 * Convert the entity instance to JSON.
119
+	 *
120
+	 * @param  int $options
121
+	 * @return string
122
+	 */
123
+	public function toJson($options = 0)
124
+	{
125
+		return json_encode($this->toArray(), $options);
126
+	}
127
+
128
+	/**
129
+	 * Convert Mappable object to array;
130
+	 *
131
+	 * @return array
132
+	 */
133
+	public function toArray()
134
+	{
135
+		return $this->attributesToArray($this->attributes);
136
+	}
137
+
138
+	/**
139
+	 * Transform the Object to array/json,
140
+	 *
141
+	 * @param  array $sourceAttributes
142
+	 * @return array
143
+	 */
144
+	protected function attributesToArray(array $sourceAttributes)
145
+	{
146
+		$attributes = [];
147
+
148
+		foreach ($sourceAttributes as $key => $attribute) {
149
+			// If the attribute is a proxy, and hasn't be loaded, we discard
150
+			// it from the returned set.
151
+			if ($attribute instanceof ProxyInterface && !$attribute->isLoaded()) {
152
+				continue;
153
+			}
154
+
155
+			if ($attribute instanceof Carbon) {
156
+				$attributes[$key] = $attribute->__toString();
157
+				continue;
158
+			}
159
+
160
+			if ($attribute instanceof Arrayable) {
161
+				$attributes[$key] = $attribute->toArray();
162
+			} else {
163
+				$attributes[$key] = $attribute;
164
+			}
165
+		}
166
+		return $attributes;
167
+	}
168 168
 }
Please login to merge, or discard this patch.
src/Plugins/SoftDeletes/Restore.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@
 block discarded – undo
6 6
 
7 7
 class Restore extends Command
8 8
 {
9
-    /**
10
-     * @throws \InvalidArgumentException
11
-     *
12
-     * @return false|mixed
13
-     */
14
-    public function execute()
15
-    {
16
-        $aggregate = $this->aggregate;
17
-        $entity = $aggregate->getEntityObject();
18
-        $mapper = $aggregate->getMapper();
19
-        $entityMap = $mapper->getEntityMap();
20
-
21
-        if ($mapper->fireEvent('restoring', $entity) === false) {
22
-            return false;
23
-        }
24
-
25
-        $keyName = $entityMap->getKeyName();
9
+	/**
10
+	 * @throws \InvalidArgumentException
11
+	 *
12
+	 * @return false|mixed
13
+	 */
14
+	public function execute()
15
+	{
16
+		$aggregate = $this->aggregate;
17
+		$entity = $aggregate->getEntityObject();
18
+		$mapper = $aggregate->getMapper();
19
+		$entityMap = $mapper->getEntityMap();
20
+
21
+		if ($mapper->fireEvent('restoring', $entity) === false) {
22
+			return false;
23
+		}
24
+
25
+		$keyName = $entityMap->getKeyName();
26 26
         
27
-        $query = $this->query->where($keyName, '=', $aggregate->getEntityAttribute($keyName));
27
+		$query = $this->query->where($keyName, '=', $aggregate->getEntityAttribute($keyName));
28 28
 
29
-        $deletedAtColumn = $entityMap->getQualifiedDeletedAtColumn();
29
+		$deletedAtColumn = $entityMap->getQualifiedDeletedAtColumn();
30 30
 
31
-        $query->update([$deletedAtColumn => null]);
31
+		$query->update([$deletedAtColumn => null]);
32 32
         
33
-        $aggregate->setEntityAttribute($deletedAtColumn, null);
33
+		$aggregate->setEntityAttribute($deletedAtColumn, null);
34 34
         
35
-        $mapper->fireEvent('restored', $entity, false);
35
+		$mapper->fireEvent('restored', $entity, false);
36 36
 
37
-        $mapper->getEntityCache()->refresh($aggregate);
37
+		$mapper->getEntityCache()->refresh($aggregate);
38 38
 
39
-        return $entity;
40
-    }
39
+		return $entity;
40
+	}
41 41
 }
Please login to merge, or discard this patch.
src/Plugins/SoftDeletes/SoftDeletesPlugin.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -13,80 +13,80 @@
 block discarded – undo
13 13
  */
14 14
 class SoftDeletesPlugin extends AnaloguePlugin
15 15
 {
16
-    /**
17
-     * Register the plugin
18
-     *
19
-     * @throws \Exception
20
-     * @return void
21
-     */
22
-    public function register()
23
-    {
24
-        $host = $this;
25
-
26
-        // Hook any mapper init and check the mapping include soft deletes.
27
-        $this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) use ($host) {
28
-            $entityMap = $mapper->getEntityMap();
29
-
30
-            if ($entityMap->usesSoftDeletes()) {
31
-                $host->registerSoftDelete($mapper);
32
-            }
33
-
34
-        });
35
-    }
36
-
37
-    /**
38
-     * By hooking to the mapper initialization event, we can extend it
39
-     * with the softDelete capacity.
40
-     *
41
-     * @param  \Analogue\ORM\System\Mapper $mapper
42
-     * @throws \Analogue\ORM\Exceptions\MappingException
43
-     * @return bool|void
44
-     */
45
-    protected function registerSoftDelete(Mapper $mapper)
46
-    {
47
-        $entityMap = $mapper->getEntityMap();
48
-
49
-        // Add Scopes
50
-        $mapper->addGlobalScope(new SoftDeletingScope);
51
-
52
-        $host = $this;
53
-
54
-        // Register 'deleting' events
55
-        $mapper->registerEvent('deleting', function ($entity) use ($entityMap, $host) {
16
+	/**
17
+	 * Register the plugin
18
+	 *
19
+	 * @throws \Exception
20
+	 * @return void
21
+	 */
22
+	public function register()
23
+	{
24
+		$host = $this;
25
+
26
+		// Hook any mapper init and check the mapping include soft deletes.
27
+		$this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) use ($host) {
28
+			$entityMap = $mapper->getEntityMap();
29
+
30
+			if ($entityMap->usesSoftDeletes()) {
31
+				$host->registerSoftDelete($mapper);
32
+			}
33
+
34
+		});
35
+	}
36
+
37
+	/**
38
+	 * By hooking to the mapper initialization event, we can extend it
39
+	 * with the softDelete capacity.
40
+	 *
41
+	 * @param  \Analogue\ORM\System\Mapper $mapper
42
+	 * @throws \Analogue\ORM\Exceptions\MappingException
43
+	 * @return bool|void
44
+	 */
45
+	protected function registerSoftDelete(Mapper $mapper)
46
+	{
47
+		$entityMap = $mapper->getEntityMap();
48
+
49
+		// Add Scopes
50
+		$mapper->addGlobalScope(new SoftDeletingScope);
51
+
52
+		$host = $this;
53
+
54
+		// Register 'deleting' events
55
+		$mapper->registerEvent('deleting', function ($entity) use ($entityMap, $host) {
56 56
             
57
-            // Convert Entity into an EntityWrapper
58
-            $factory = new Factory;
57
+			// Convert Entity into an EntityWrapper
58
+			$factory = new Factory;
59 59
 
60
-            $wrappedEntity = $factory->make($entity);
60
+			$wrappedEntity = $factory->make($entity);
61 61
 
62
-            $deletedAtField = $entityMap->getQualifiedDeletedAtColumn();
62
+			$deletedAtField = $entityMap->getQualifiedDeletedAtColumn();
63 63
 
64
-            if (!is_null($wrappedEntity->getEntityAttribute($deletedAtField))) {
65
-                return true;
66
-            } else {
67
-                $time = new Carbon;
64
+			if (!is_null($wrappedEntity->getEntityAttribute($deletedAtField))) {
65
+				return true;
66
+			} else {
67
+				$time = new Carbon;
68 68
 
69
-                $wrappedEntity->setEntityAttribute($deletedAtField, $time);
69
+				$wrappedEntity->setEntityAttribute($deletedAtField, $time);
70 70
 
71
-                $plainObject = $wrappedEntity->getObject();
72
-                $host->manager->mapper(get_class($plainObject))->store($plainObject);
71
+				$plainObject = $wrappedEntity->getObject();
72
+				$host->manager->mapper(get_class($plainObject))->store($plainObject);
73 73
 
74
-                return false;
75
-            }
74
+				return false;
75
+			}
76 76
 
77
-        });
77
+		});
78 78
 
79
-        // Register RestoreCommand
80
-        $mapper->addCustomCommand('Analogue\ORM\Plugins\SoftDeletes\Restore');
81
-    }
79
+		// Register RestoreCommand
80
+		$mapper->addCustomCommand('Analogue\ORM\Plugins\SoftDeletes\Restore');
81
+	}
82 82
 
83
-    /**
84
-     * Get custom events provided by the plugin
85
-     *
86
-     * @return string[]
87
-     */
88
-    public function getCustomEvents()
89
-    {
90
-        return ['restoring', 'restored'];
91
-    }
83
+	/**
84
+	 * Get custom events provided by the plugin
85
+	 *
86
+	 * @return string[]
87
+	 */
88
+	public function getCustomEvents()
89
+	{
90
+		return ['restoring', 'restored'];
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $host = $this;
25 25
 
26 26
         // Hook any mapper init and check the mapping include soft deletes.
27
-        $this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) use ($host) {
27
+        $this->manager->registerGlobalEvent('initialized', function(Mapper $mapper) use ($host) {
28 28
             $entityMap = $mapper->getEntityMap();
29 29
 
30 30
             if ($entityMap->usesSoftDeletes()) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $host = $this;
53 53
 
54 54
         // Register 'deleting' events
55
-        $mapper->registerEvent('deleting', function ($entity) use ($entityMap, $host) {
55
+        $mapper->registerEvent('deleting', function($entity) use ($entityMap, $host) {
56 56
             
57 57
             // Convert Entity into an EntityWrapper
58 58
             $factory = new Factory;
Please login to merge, or discard this patch.
src/Plugins/Timestamps/TimestampsPlugin.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,55 +12,55 @@
 block discarded – undo
12 12
  */
13 13
 class TimestampsPlugin extends AnaloguePlugin
14 14
 {
15
-    /**
16
-     * Register the plugin
17
-     *
18
-     * @throws \Exception
19
-     * @return void
20
-     */
21
-    public function register()
22
-    {
23
-        $this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) {
24
-            $entityMap = $mapper->getEntityMap();
15
+	/**
16
+	 * Register the plugin
17
+	 *
18
+	 * @throws \Exception
19
+	 * @return void
20
+	 */
21
+	public function register()
22
+	{
23
+		$this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) {
24
+			$entityMap = $mapper->getEntityMap();
25 25
 
26
-            if ($entityMap->usesTimestamps()) {
27
-                $mapper->registerEvent('creating', function ($entity) use ($entityMap) {
26
+			if ($entityMap->usesTimestamps()) {
27
+				$mapper->registerEvent('creating', function ($entity) use ($entityMap) {
28 28
 
29
-                    $factory = new Factory;
30
-                    $wrappedEntity = $factory->make($entity);
29
+					$factory = new Factory;
30
+					$wrappedEntity = $factory->make($entity);
31 31
 
32
-                    $createdAtField = $entityMap->getCreatedAtColumn();
33
-                    $updatedAtField = $entityMap->getUpdatedAtColumn();
32
+					$createdAtField = $entityMap->getCreatedAtColumn();
33
+					$updatedAtField = $entityMap->getUpdatedAtColumn();
34 34
 
35
-                    $time = new Carbon;
35
+					$time = new Carbon;
36 36
 
37
-                    $wrappedEntity->setEntityAttribute($createdAtField, $time);
38
-                    $wrappedEntity->setEntityAttribute($updatedAtField, $time);
37
+					$wrappedEntity->setEntityAttribute($createdAtField, $time);
38
+					$wrappedEntity->setEntityAttribute($updatedAtField, $time);
39 39
 
40
-                });
40
+				});
41 41
 
42
-                $mapper->registerEvent('updating', function ($entity) use ($entityMap) {
42
+				$mapper->registerEvent('updating', function ($entity) use ($entityMap) {
43 43
 
44
-                    $factory = new Factory;
45
-                    $wrappedEntity = $factory->make($entity);
44
+					$factory = new Factory;
45
+					$wrappedEntity = $factory->make($entity);
46 46
 
47
-                    $updatedAtField = $entityMap->getUpdatedAtColumn();
47
+					$updatedAtField = $entityMap->getUpdatedAtColumn();
48 48
 
49
-                    $time = new Carbon;
49
+					$time = new Carbon;
50 50
 
51
-                    $wrappedEntity->setEntityAttribute($updatedAtField, $time);
52
-                });
53
-            }
54
-        });
55
-    }
51
+					$wrappedEntity->setEntityAttribute($updatedAtField, $time);
52
+				});
53
+			}
54
+		});
55
+	}
56 56
 
57
-    /**
58
-     * Get custom events provided by the plugin
59
-     *
60
-     * @return array
61
-     */
62
-    public function getCustomEvents()
63
-    {
64
-        return [];
65
-    }
57
+	/**
58
+	 * Get custom events provided by the plugin
59
+	 *
60
+	 * @return array
61
+	 */
62
+	public function getCustomEvents()
63
+	{
64
+		return [];
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function register()
22 22
     {
23
-        $this->manager->registerGlobalEvent('initialized', function (Mapper $mapper) {
23
+        $this->manager->registerGlobalEvent('initialized', function(Mapper $mapper) {
24 24
             $entityMap = $mapper->getEntityMap();
25 25
 
26 26
             if ($entityMap->usesTimestamps()) {
27
-                $mapper->registerEvent('creating', function ($entity) use ($entityMap) {
27
+                $mapper->registerEvent('creating', function($entity) use ($entityMap) {
28 28
 
29 29
                     $factory = new Factory;
30 30
                     $wrappedEntity = $factory->make($entity);
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
                 });
41 41
 
42
-                $mapper->registerEvent('updating', function ($entity) use ($entityMap) {
42
+                $mapper->registerEvent('updating', function($entity) use ($entityMap) {
43 43
 
44 44
                     $factory = new Factory;
45 45
                     $wrappedEntity = $factory->make($entity);
Please login to merge, or discard this patch.
src/Plugins/AnaloguePlugin.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
 
7 7
 abstract class AnaloguePlugin implements AnaloguePluginInterface
8 8
 {
9
-    /**
10
-     * Manager instance
11
-     *
12
-     * @var Manager
13
-     */
14
-    protected $manager;
9
+	/**
10
+	 * Manager instance
11
+	 *
12
+	 * @var Manager
13
+	 */
14
+	protected $manager;
15 15
 
16
-    /**
17
-     * AnaloguePlugin constructor.
18
-     * @param Manager $manager
19
-     */
20
-    public function __construct(Manager $manager)
21
-    {
22
-        $this->manager = $manager;
23
-    }
16
+	/**
17
+	 * AnaloguePlugin constructor.
18
+	 * @param Manager $manager
19
+	 */
20
+	public function __construct(Manager $manager)
21
+	{
22
+		$this->manager = $manager;
23
+	}
24 24
 
25
-    /**
26
-     * Boot the plugin
27
-     *
28
-     * @return void
29
-     */
30
-    abstract public function register();
25
+	/**
26
+	 * Boot the plugin
27
+	 *
28
+	 * @return void
29
+	 */
30
+	abstract public function register();
31 31
 
32
-    /**
33
-     * Get custom events provided by the plugin
34
-     *
35
-     * @return array
36
-     */
37
-    abstract public function getCustomEvents();
32
+	/**
33
+	 * Get custom events provided by the plugin
34
+	 *
35
+	 * @return array
36
+	 */
37
+	abstract public function getCustomEvents();
38 38
 }
Please login to merge, or discard this patch.
src/Repository.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -15,129 +15,129 @@
 block discarded – undo
15 15
  */
16 16
 class Repository
17 17
 {
18
-    /**
19
-     * The mapper object for the corresponding entity
20
-     *
21
-     * @var \Analogue\ORM\System\Mapper
22
-     */
23
-    protected $mapper;
18
+	/**
19
+	 * The mapper object for the corresponding entity
20
+	 *
21
+	 * @var \Analogue\ORM\System\Mapper
22
+	 */
23
+	protected $mapper;
24 24
 
25
-    /**
26
-     * To build a repository, either provide :
27
-     *
28
-     * - Mappable object's class name as a string
29
-     * - Mappable object instance
30
-     * - Instance of mapper
31
-     *
32
-     * @param  Mapper         $mapper
33
-     * @param  EntityMap|null $entityMap (optional)
34
-     * @throws \InvalidArgumentException
35
-     * @throws MappingException
36
-     */
37
-    public function __construct($mapper, EntityMap $entityMap = null)
38
-    {
39
-        if ($mapper instanceof Mappable || is_string($mapper)) {
40
-            $this->mapper = Manager::getMapper($mapper, $entityMap);
41
-        } elseif ($mapper instanceof Mapper) {
42
-            $this->mapper = $mapper;
43
-        } else {
44
-            new InvalidArgumentException('Repository class constructor need a valid Mapper or Mappable object.');
45
-        }
46
-    }
25
+	/**
26
+	 * To build a repository, either provide :
27
+	 *
28
+	 * - Mappable object's class name as a string
29
+	 * - Mappable object instance
30
+	 * - Instance of mapper
31
+	 *
32
+	 * @param  Mapper         $mapper
33
+	 * @param  EntityMap|null $entityMap (optional)
34
+	 * @throws \InvalidArgumentException
35
+	 * @throws MappingException
36
+	 */
37
+	public function __construct($mapper, EntityMap $entityMap = null)
38
+	{
39
+		if ($mapper instanceof Mappable || is_string($mapper)) {
40
+			$this->mapper = Manager::getMapper($mapper, $entityMap);
41
+		} elseif ($mapper instanceof Mapper) {
42
+			$this->mapper = $mapper;
43
+		} else {
44
+			new InvalidArgumentException('Repository class constructor need a valid Mapper or Mappable object.');
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * Return all Entities from database
50
-     *
51
-     * @return \Analogue\ORM\EntityCollection
52
-     */
53
-    public function all()
54
-    {
55
-        return $this->mapper->get();
56
-    }
48
+	/**
49
+	 * Return all Entities from database
50
+	 *
51
+	 * @return \Analogue\ORM\EntityCollection
52
+	 */
53
+	public function all()
54
+	{
55
+		return $this->mapper->get();
56
+	}
57 57
     
58
-    /**
59
-     * Fetch a record from the database
60
-     * @param  integer $id
61
-     * @return \Analogue\ORM\Mappable
62
-     */
63
-    public function find($id)
64
-    {
65
-        return $this->mapper->find($id);
66
-    }
58
+	/**
59
+	 * Fetch a record from the database
60
+	 * @param  integer $id
61
+	 * @return \Analogue\ORM\Mappable
62
+	 */
63
+	public function find($id)
64
+	{
65
+		return $this->mapper->find($id);
66
+	}
67 67
 
68
-    /**
69
-     * Get the first entity matching the given attributes.
70
-     *
71
-     * @param  array  $attributes
72
-     * @return \Analogue\ORM\Mappable|null
73
-     */
74
-    public function firstMatching(array $attributes)
75
-    {
76
-        return $this->mapper->where($attributes)->first();
77
-    }
68
+	/**
69
+	 * Get the first entity matching the given attributes.
70
+	 *
71
+	 * @param  array  $attributes
72
+	 * @return \Analogue\ORM\Mappable|null
73
+	 */
74
+	public function firstMatching(array $attributes)
75
+	{
76
+		return $this->mapper->where($attributes)->first();
77
+	}
78 78
 
79
-    /**
80
-     * Return all the entities matching the given attributes
81
-     *
82
-     * @param array $attributes
83
-     * @return \Analogue\ORM\EntityCollection
84
-     */
85
-    public function allMatching(array $attributes)
86
-    {
87
-        return $this->mapper->where($attributes)->get();
88
-    }
79
+	/**
80
+	 * Return all the entities matching the given attributes
81
+	 *
82
+	 * @param array $attributes
83
+	 * @return \Analogue\ORM\EntityCollection
84
+	 */
85
+	public function allMatching(array $attributes)
86
+	{
87
+		return $this->mapper->where($attributes)->get();
88
+	}
89 89
 
90
-    /**
91
-     * Return a paginator instance on the EntityCollection
92
-     *
93
-     * @param int|null $perPage number of item per page (fallback on default setup in entity map)
94
-     * @return \Illuminate\Pagination\LengthAwarePaginator
95
-     */
96
-    public function paginate($perPage = null)
97
-    {
98
-        return $this->mapper->paginate($perPage);
99
-    }
90
+	/**
91
+	 * Return a paginator instance on the EntityCollection
92
+	 *
93
+	 * @param int|null $perPage number of item per page (fallback on default setup in entity map)
94
+	 * @return \Illuminate\Pagination\LengthAwarePaginator
95
+	 */
96
+	public function paginate($perPage = null)
97
+	{
98
+		return $this->mapper->paginate($perPage);
99
+	}
100 100
 
101
-    /**
102
-     * Delete an entity or an entity collection from the database
103
-     *
104
-     * @param  Mappable|EntityCollection $entity
105
-     * @throws MappingException
106
-     * @throws \InvalidArgumentException
107
-     * @return \Illuminate\Support\Collection|null
108
-     */
109
-    public function delete($entity)
110
-    {
111
-        return $this->mapper->delete($entity);
112
-    }
101
+	/**
102
+	 * Delete an entity or an entity collection from the database
103
+	 *
104
+	 * @param  Mappable|EntityCollection $entity
105
+	 * @throws MappingException
106
+	 * @throws \InvalidArgumentException
107
+	 * @return \Illuminate\Support\Collection|null
108
+	 */
109
+	public function delete($entity)
110
+	{
111
+		return $this->mapper->delete($entity);
112
+	}
113 113
 
114
-    /**
115
-     * Persist an entity or an entity collection in the database.
116
-     *
117
-     * @param  Mappable|EntityCollection|array $entity
118
-     * @throws MappingException
119
-     * @throws \InvalidArgumentException
120
-     * @return Mappable|EntityCollection|array
121
-     */
122
-    public function store($entity)
123
-    {
124
-        return $this->mapper->store($entity);
125
-    }
114
+	/**
115
+	 * Persist an entity or an entity collection in the database.
116
+	 *
117
+	 * @param  Mappable|EntityCollection|array $entity
118
+	 * @throws MappingException
119
+	 * @throws \InvalidArgumentException
120
+	 * @return Mappable|EntityCollection|array
121
+	 */
122
+	public function store($entity)
123
+	{
124
+		return $this->mapper->store($entity);
125
+	}
126 126
 
127
-    /**
128
-     * Make custom mapper custom commands available in repository
129
-     *
130
-     * @param  string $method
131
-     * @param  array  $parameters
132
-     * @throws Exception
133
-     * @return mixed
134
-     */
135
-    public function __call($method, $parameters)
136
-    {
137
-        if ($this->mapper->hasCustomCommand($method)) {
138
-            call_user_func_array([$this->mapper, $method], $parameters);
139
-        } else {
140
-            throw new Exception("No method $method on " . get_class($this));
141
-        }
142
-    }
127
+	/**
128
+	 * Make custom mapper custom commands available in repository
129
+	 *
130
+	 * @param  string $method
131
+	 * @param  array  $parameters
132
+	 * @throws Exception
133
+	 * @return mixed
134
+	 */
135
+	public function __call($method, $parameters)
136
+	{
137
+		if ($this->mapper->hasCustomCommand($method)) {
138
+			call_user_func_array([$this->mapper, $method], $parameters);
139
+		} else {
140
+			throw new Exception("No method $method on " . get_class($this));
141
+		}
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
         if ($this->mapper->hasCustomCommand($method)) {
138 138
             call_user_func_array([$this->mapper, $method], $parameters);
139 139
         } else {
140
-            throw new Exception("No method $method on " . get_class($this));
140
+            throw new Exception("No method $method on ".get_class($this));
141 141
         }
142 142
     }
143 143
 }
Please login to merge, or discard this patch.
src/MappableTrait.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -8,63 +8,63 @@
 block discarded – undo
8 8
  */
9 9
 trait MappableTrait
10 10
 {
11
-    /**
12
-     * The Entity's Attributes
13
-     * @var array
14
-     */
15
-    protected $attributes = [];
11
+	/**
12
+	 * The Entity's Attributes
13
+	 * @var array
14
+	 */
15
+	protected $attributes = [];
16 16
 
17
-    /**
18
-     * Method used by the mapper to set the object
19
-     * attribute raw values (hydration)
20
-     *
21
-     * @param array $attributes
22
-     *
23
-     * @return void
24
-     */
25
-    public function setEntityAttributes(array $attributes)
26
-    {
27
-        $this->attributes = $attributes;
28
-    }
17
+	/**
18
+	 * Method used by the mapper to set the object
19
+	 * attribute raw values (hydration)
20
+	 *
21
+	 * @param array $attributes
22
+	 *
23
+	 * @return void
24
+	 */
25
+	public function setEntityAttributes(array $attributes)
26
+	{
27
+		$this->attributes = $attributes;
28
+	}
29 29
 
30
-    /**
31
-     * Method used by the mapper to get the
32
-     * raw object's values.
33
-     *
34
-     * @return array
35
-     */
36
-    public function getEntityAttributes()
37
-    {
38
-        return $this->attributes;
39
-    }
30
+	/**
31
+	 * Method used by the mapper to get the
32
+	 * raw object's values.
33
+	 *
34
+	 * @return array
35
+	 */
36
+	public function getEntityAttributes()
37
+	{
38
+		return $this->attributes;
39
+	}
40 40
 
41
-    /**
42
-     * Method used by the mapper to set raw
43
-     * key-value pair
44
-     *
45
-     * @param string $key
46
-     * @param string $value
47
-     *
48
-     * @return void
49
-     */
50
-    public function setEntityAttribute($key, $value)
51
-    {
52
-        $this->attributes[$key] = $value;
53
-    }
41
+	/**
42
+	 * Method used by the mapper to set raw
43
+	 * key-value pair
44
+	 *
45
+	 * @param string $key
46
+	 * @param string $value
47
+	 *
48
+	 * @return void
49
+	 */
50
+	public function setEntityAttribute($key, $value)
51
+	{
52
+		$this->attributes[$key] = $value;
53
+	}
54 54
 
55
-    /**
56
-     * Method used by the mapper to get single
57
-     * key-value pair
58
-     *
59
-     * @param  string $key
60
-     * @return mixed|null
61
-     */
62
-    public function getEntityAttribute($key)
63
-    {
64
-        if (array_key_exists($key, $this->attributes)) {
65
-            return $this->attributes[$key];
66
-        } else {
67
-            return null;
68
-        }
69
-    }
55
+	/**
56
+	 * Method used by the mapper to get single
57
+	 * key-value pair
58
+	 *
59
+	 * @param  string $key
60
+	 * @return mixed|null
61
+	 */
62
+	public function getEntityAttribute($key)
63
+	{
64
+		if (array_key_exists($key, $this->attributes)) {
65
+			return $this->attributes[$key];
66
+		} else {
67
+			return null;
68
+		}
69
+	}
70 70
 }
Please login to merge, or discard this patch.