Completed
Push — 5.1 ( 8f5aa6...9105b9 )
by Rémi
7s
created
src/Entity.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -6,113 +6,113 @@
 block discarded – undo
6 6
 
7 7
 class Entity extends ValueObject
8 8
 {
9
-    /**
10
-     * Entities Hidden Attributes, that will be discarded when converting
11
-     * the entity to Array/Json
12
-     * (can include any embedded object's attribute)
13
-     *
14
-     * @var array
15
-     */
16
-    protected $hidden = [];
9
+	/**
10
+	 * Entities Hidden Attributes, that will be discarded when converting
11
+	 * the entity to Array/Json
12
+	 * (can include any embedded object's attribute)
13
+	 *
14
+	 * @var array
15
+	 */
16
+	protected $hidden = [];
17 17
 
18
-    /**
19
-     * Return the entity's attribute
20
-     * @param  string $key
21
-     * @return mixed
22
-     */
23
-    public function __get($key)
24
-    {
25
-        if ($this->hasGetMutator($key)) {
26
-            $method = 'get' . $this->getMutatorMethod($key);
18
+	/**
19
+	 * Return the entity's attribute
20
+	 * @param  string $key
21
+	 * @return mixed
22
+	 */
23
+	public function __get($key)
24
+	{
25
+		if ($this->hasGetMutator($key)) {
26
+			$method = 'get' . $this->getMutatorMethod($key);
27 27
 
28
-            $attribute = null;
28
+			$attribute = null;
29 29
 
30
-            if (isset($this->attributes[$key])) {
31
-                $attribute = $this->attributes[$key];
32
-            }
30
+			if (isset($this->attributes[$key])) {
31
+				$attribute = $this->attributes[$key];
32
+			}
33 33
 
34
-            return $this->$method($attribute);
35
-        }
36
-        if (!array_key_exists($key, $this->attributes)) {
37
-            return null;
38
-        }
39
-        if ($this->attributes[$key] instanceof EntityProxy) {
40
-            $this->attributes[$key] = $this->attributes[$key]->load();
41
-        }
42
-        return $this->attributes[$key];
43
-    }
34
+			return $this->$method($attribute);
35
+		}
36
+		if (!array_key_exists($key, $this->attributes)) {
37
+			return null;
38
+		}
39
+		if ($this->attributes[$key] instanceof EntityProxy) {
40
+			$this->attributes[$key] = $this->attributes[$key]->load();
41
+		}
42
+		return $this->attributes[$key];
43
+	}
44 44
 
45
-    /**
46
-     * Dynamically set attributes on the entity.
47
-     *
48
-     * @param  string $key
49
-     * @param  mixed  $value
50
-     * @return void
51
-     */
52
-    public function __set($key, $value)
53
-    {
54
-        if ($this->hasSetMutator($key)) {
55
-            $method = 'set' . $this->getMutatorMethod($key);
45
+	/**
46
+	 * Dynamically set attributes on the entity.
47
+	 *
48
+	 * @param  string $key
49
+	 * @param  mixed  $value
50
+	 * @return void
51
+	 */
52
+	public function __set($key, $value)
53
+	{
54
+		if ($this->hasSetMutator($key)) {
55
+			$method = 'set' . $this->getMutatorMethod($key);
56 56
 
57
-            $this->$method($value);
58
-        } else {
59
-            $this->attributes[$key] = $value;
60
-        }
61
-    }
57
+			$this->$method($value);
58
+		} else {
59
+			$this->attributes[$key] = $value;
60
+		}
61
+	}
62 62
 
63
-    /**
64
-     * Is a getter method defined ?
65
-     *
66
-     * @param  string $key
67
-     * @return boolean
68
-     */
69
-    protected function hasGetMutator($key)
70
-    {
71
-        return method_exists($this, 'get' . $this->getMutatorMethod($key)) ? true : false;
72
-    }
63
+	/**
64
+	 * Is a getter method defined ?
65
+	 *
66
+	 * @param  string $key
67
+	 * @return boolean
68
+	 */
69
+	protected function hasGetMutator($key)
70
+	{
71
+		return method_exists($this, 'get' . $this->getMutatorMethod($key)) ? true : false;
72
+	}
73 73
 
74
-    /**
75
-     * Is a setter method defined ?
76
-     *
77
-     * @param  string $key
78
-     * @return boolean
79
-     */
80
-    protected function hasSetMutator($key)
81
-    {
82
-        return method_exists($this, 'set' . $this->getMutatorMethod($key)) ? true : false;
83
-    }
74
+	/**
75
+	 * Is a setter method defined ?
76
+	 *
77
+	 * @param  string $key
78
+	 * @return boolean
79
+	 */
80
+	protected function hasSetMutator($key)
81
+	{
82
+		return method_exists($this, 'set' . $this->getMutatorMethod($key)) ? true : false;
83
+	}
84 84
 
85
-    /**
86
-     * @param $key
87
-     * @return string
88
-     */
89
-    protected function getMutatorMethod($key)
90
-    {
91
-        $key = ucwords(str_replace(['-', '_'], ' ', $key));
92
-        return str_replace(' ', '', $key) . "Attribute";
93
-    }
85
+	/**
86
+	 * @param $key
87
+	 * @return string
88
+	 */
89
+	protected function getMutatorMethod($key)
90
+	{
91
+		$key = ucwords(str_replace(['-', '_'], ' ', $key));
92
+		return str_replace(' ', '', $key) . "Attribute";
93
+	}
94 94
 
95
-    /**
96
-     * Convert every attributes to value / arrays
97
-     *
98
-     * @return array
99
-     */
100
-    public function toArray()
101
-    {
102
-        // First, call the trait method before filtering
103
-        // with Entity specific methods
104
-        $attributes = $this->attributesToArray($this->attributes);
95
+	/**
96
+	 * Convert every attributes to value / arrays
97
+	 *
98
+	 * @return array
99
+	 */
100
+	public function toArray()
101
+	{
102
+		// First, call the trait method before filtering
103
+		// with Entity specific methods
104
+		$attributes = $this->attributesToArray($this->attributes);
105 105
 
106
-        foreach ($this->attributes as $key => $attribute) {
107
-            if (in_array($key, $this->hidden)) {
108
-                unset($attributes[$key]);
109
-                continue;
110
-            }
111
-            if ($this->hasGetMutator($key)) {
112
-                $method = 'get' . $this->getMutatorMethod($key);
113
-                $attributes[$key] = $this->$method($attribute);
114
-            }
115
-        }
116
-        return $attributes;
117
-    }
106
+		foreach ($this->attributes as $key => $attribute) {
107
+			if (in_array($key, $this->hidden)) {
108
+				unset($attributes[$key]);
109
+				continue;
110
+			}
111
+			if ($this->hasGetMutator($key)) {
112
+				$method = 'get' . $this->getMutatorMethod($key);
113
+				$attributes[$key] = $this->$method($attribute);
114
+			}
115
+		}
116
+		return $attributes;
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function __get($key)
24 24
     {
25 25
         if ($this->hasGetMutator($key)) {
26
-            $method = 'get' . $this->getMutatorMethod($key);
26
+            $method = 'get'.$this->getMutatorMethod($key);
27 27
 
28 28
             $attribute = null;
29 29
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function __set($key, $value)
53 53
     {
54 54
         if ($this->hasSetMutator($key)) {
55
-            $method = 'set' . $this->getMutatorMethod($key);
55
+            $method = 'set'.$this->getMutatorMethod($key);
56 56
 
57 57
             $this->$method($value);
58 58
         } else {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     protected function hasGetMutator($key)
70 70
     {
71
-        return method_exists($this, 'get' . $this->getMutatorMethod($key)) ? true : false;
71
+        return method_exists($this, 'get'.$this->getMutatorMethod($key)) ? true : false;
72 72
     }
73 73
 
74 74
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     protected function hasSetMutator($key)
81 81
     {
82
-        return method_exists($this, 'set' . $this->getMutatorMethod($key)) ? true : false;
82
+        return method_exists($this, 'set'.$this->getMutatorMethod($key)) ? true : false;
83 83
     }
84 84
 
85 85
     /**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     protected function getMutatorMethod($key)
90 90
     {
91 91
         $key = ucwords(str_replace(['-', '_'], ' ', $key));
92
-        return str_replace(' ', '', $key) . "Attribute";
92
+        return str_replace(' ', '', $key)."Attribute";
93 93
     }
94 94
 
95 95
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 continue;
110 110
             }
111 111
             if ($this->hasGetMutator($key)) {
112
-                $method = 'get' . $this->getMutatorMethod($key);
112
+                $method = 'get'.$this->getMutatorMethod($key);
113 113
                 $attributes[$key] = $this->$method($attribute);
114 114
             }
115 115
         }
Please login to merge, or discard this patch.