Passed
Push — master ( b87bd2...81711e )
by Sebastian
03:45
created
src/Mailcode/Parser/Safeguard/Placeholder/Locator/Replacer.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,49 +32,49 @@  discard block
 block discarded – undo
32 32
     const ERROR_COULD_NOT_FIND_PLACEHOLDER_TEXT = 63502;
33 33
     const ERROR_PLACEHOLDER_POSITION_ERRONEOUS = 63503;
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     private $replacementText;
39 39
     
40
-   /**
41
-    * @var Mailcode_Parser_Safeguard_Placeholder_Locator
42
-    */
40
+    /**
41
+     * @var Mailcode_Parser_Safeguard_Placeholder_Locator
42
+     */
43 43
     private $locator;
44 44
     
45
-   /**
46
-    * @var Mailcode_Parser_Safeguard_Placeholder_Locator_Location
47
-    */
45
+    /**
46
+     * @var Mailcode_Parser_Safeguard_Placeholder_Locator_Location
47
+     */
48 48
     private $origin;
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     private $placeholderText;
54 54
     
55
-   /**
56
-    * @var integer
57
-    */
55
+    /**
56
+     * @var integer
57
+     */
58 58
     private $offset = 0;
59 59
     
60
-   /**
61
-    * @var string
62
-    */
60
+    /**
61
+     * @var string
62
+     */
63 63
     private $subject;
64 64
     
65
-   /**
66
-    * @var integer
67
-    */
65
+    /**
66
+     * @var integer
67
+     */
68 68
     private $placeholderOffset = 0;
69 69
 
70
-   /**
71
-    * @var integer
72
-    */
70
+    /**
71
+     * @var integer
72
+     */
73 73
     private $placeholderLength = 0;
74 74
 
75
-   /**
76
-    * @var integer
77
-    */
75
+    /**
76
+     * @var integer
77
+     */
78 78
     private $lengthDifference = 0;
79 79
     
80 80
     public function __construct(Mailcode_Parser_Safeguard_Placeholder_Locator $locator, Mailcode_Parser_Safeguard_Placeholder_Locator_Location $origin, string $replacementText, string $subject)
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
         $this->adjustPositions();
94 94
     }
95 95
     
96
-   /**
97
-    * Adjusts the positions of all locations that come after 
98
-    * this one, to account for the added string length of the
99
-    * placeholder that has been replaced.
100
-    */
96
+    /**
97
+     * Adjusts the positions of all locations that come after 
98
+     * this one, to account for the added string length of the
99
+     * placeholder that has been replaced.
100
+     */
101 101
     private function adjustPositions() : void
102 102
     {
103 103
         $locations = $this->origin->getNextAll();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $locations = $this->origin->getNextAll();
104 104
         $offset = $this->lengthDifference;
105 105
 
106
-        foreach($locations as $location)
106
+        foreach ($locations as $location)
107 107
         {
108 108
             $location->updatePositionByOffset($offset);
109 109
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $length = mb_strpos($this->replacementText, $this->placeholderText);
115 115
         
116
-        if($length === false)
116
+        if ($length === false)
117 117
         {
118 118
             throw new Mailcode_Exception(
119 119
                 'Replacement text does not contain placeholder string.',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         // Failsafe check: the calculated new position
150 150
         // in the subject string should still equal the
151 151
         // placeholder string.
152
-        if($placeholder != $this->placeholderText)
152
+        if ($placeholder != $this->placeholderText)
153 153
         {
154 154
             throw new Mailcode_Exception(
155 155
                 'Localizing a safeguard placeholder failed.',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Placeholder/Locator/Location.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,29 +23,29 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class Mailcode_Parser_Safeguard_Placeholder_Locator_Location
25 25
 {
26
-   /**
27
-    * @var Mailcode_Parser_Safeguard_Placeholder
28
-    */
26
+    /**
27
+     * @var Mailcode_Parser_Safeguard_Placeholder
28
+     */
29 29
     private $placeholder;
30 30
     
31
-   /**
32
-    * @var int
33
-    */
31
+    /**
32
+     * @var int
33
+     */
34 34
     private $startPos;
35 35
     
36
-   /**
37
-    * @var int
38
-    */
36
+    /**
37
+     * @var int
38
+     */
39 39
     private $length;
40 40
     
41
-   /**
42
-    * @var int
43
-    */
41
+    /**
42
+     * @var int
43
+     */
44 44
     private $index;
45 45
     
46
-   /**
47
-    * @var Mailcode_Parser_Safeguard_Placeholder_Locator
48
-    */
46
+    /**
47
+     * @var Mailcode_Parser_Safeguard_Placeholder_Locator
48
+     */
49 49
     private $locator;
50 50
     
51 51
     public function __construct(Mailcode_Parser_Safeguard_Placeholder_Locator $locator, Mailcode_Parser_Safeguard_Placeholder $placeholder, int $index, int $startPos, int $length)
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
         return $this->getPrevious() !== null;
118 118
     }
119 119
     
120
-   /**
121
-    * Retrieves the placeholder location right after this one, if any.
122
-    * 
123
-    * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
124
-    */
120
+    /**
121
+     * Retrieves the placeholder location right after this one, if any.
122
+     * 
123
+     * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
124
+     */
125 125
     public function getNext() : ?Mailcode_Parser_Safeguard_Placeholder_Locator_Location
126 126
     {
127 127
         return $this->locator->getLocationByIndex(($this->index-1));
128 128
     }
129 129
     
130
-   /**
131
-    * Retrieves the placeholder location right before this one, if any.
132
-    * 
133
-    * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
134
-    */
130
+    /**
131
+     * Retrieves the placeholder location right before this one, if any.
132
+     * 
133
+     * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
134
+     */
135 135
     public function getPrevious() : ?Mailcode_Parser_Safeguard_Placeholder_Locator_Location
136 136
     {
137 137
         return $this->locator->getLocationByIndex(($this->index+1));
138 138
     }
139 139
     
140
-   /**
141
-    * Retrieves all placeholder locations that come after this one, if any.
142
-    * 
143
-    * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
144
-    */
140
+    /**
141
+     * Retrieves all placeholder locations that come after this one, if any.
142
+     * 
143
+     * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
144
+     */
145 145
     public function getNextAll() : array
146 146
     {
147 147
         $locations = $this->locator->getLocations();
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
         return array_slice($locations, $this->index+1);
150 150
     }
151 151
     
152
-   /**
153
-    * Called when the location has been moved in the subject string.
154
-    * @param int $offset
155
-    */
152
+    /**
153
+     * Called when the location has been moved in the subject string.
154
+     * @param int $offset
155
+     */
156 156
     public function updatePositionByOffset(int $offset) : void
157 157
     {
158 158
         $this->startPos += $offset;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     */
125 125
     public function getNext() : ?Mailcode_Parser_Safeguard_Placeholder_Locator_Location
126 126
     {
127
-        return $this->locator->getLocationByIndex(($this->index-1));
127
+        return $this->locator->getLocationByIndex(($this->index - 1));
128 128
     }
129 129
     
130 130
    /**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     */
135 135
     public function getPrevious() : ?Mailcode_Parser_Safeguard_Placeholder_Locator_Location
136 136
     {
137
-        return $this->locator->getLocationByIndex(($this->index+1));
137
+        return $this->locator->getLocationByIndex(($this->index + 1));
138 138
     }
139 139
     
140 140
    /**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         $locations = $this->locator->getLocations();
148 148
         
149
-        return array_slice($locations, $this->index+1);
149
+        return array_slice($locations, $this->index + 1);
150 150
     }
151 151
     
152 152
    /**
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Placeholder/Locator.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class Mailcode_Parser_Safeguard_Placeholder_Locator
31 31
 {
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     private $subject;
36 36
     
37
-   /**
38
-    * @var Mailcode_Parser_Safeguard_Placeholder
39
-    */
37
+    /**
38
+     * @var Mailcode_Parser_Safeguard_Placeholder
39
+     */
40 40
     private $placeholder;
41 41
     
42
-   /**
43
-    * @var Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
44
-    */
42
+    /**
43
+     * @var Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
44
+     */
45 45
     private $instances = array();
46 46
     
47 47
     public function __construct(Mailcode_Parser_Safeguard_Placeholder $placeholder, string $subject)
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
         $this->localizeInstances();
53 53
     }
54 54
     
55
-   /**
56
-    * Attempts to find the placeholder's instances in the
57
-    * target string, and returns a location instance for
58
-    * each, which allows accessing their exact position.
59
-    */
55
+    /**
56
+     * Attempts to find the placeholder's instances in the
57
+     * target string, and returns a location instance for
58
+     * each, which allows accessing their exact position.
59
+     */
60 60
     private function localizeInstances() : void
61 61
     {
62 62
         $lastPos = 0;
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
         }
82 82
     }
83 83
     
84
-   /**
85
-    * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
86
-    */
84
+    /**
85
+     * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location[]
86
+     */
87 87
     public function getLocations() : array
88 88
     {
89 89
         return $this->instances;
90 90
     }
91 91
     
92
-   /**
93
-    * Retrieves a location by its index in the locations list (in 
94
-    * ascending order as found in the subject string, zero based.)
95
-    * 
96
-    * @param int $index
97
-    * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
98
-    */
92
+    /**
93
+     * Retrieves a location by its index in the locations list (in 
94
+     * ascending order as found in the subject string, zero based.)
95
+     * 
96
+     * @param int $index
97
+     * @return Mailcode_Parser_Safeguard_Placeholder_Locator_Location|NULL
98
+     */
99 99
     public function getLocationByIndex(int $index) : ?Mailcode_Parser_Safeguard_Placeholder_Locator_Location
100 100
     {
101 101
         if(isset($this->instances[$index]))
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
         return null;
107 107
     }
108 108
     
109
-   /**
110
-    * Replaces the placeholder at the location with the specified
111
-    * replacement text.
112
-    * 
113
-    * NOTE: The replacement text MUST contain the original placeholder
114
-    * for this to work. An exception will be triggered otherwise.
115
-    * 
116
-    * @param Mailcode_Parser_Safeguard_Placeholder_Locator_Location $location
117
-    * @param string $replacementText
118
-    * @throws Mailcode_Exception
119
-    * 
120
-    * @see Mailcode_Parser_Safeguard_Placeholder_Locator_Replacer::ERROR_PLACEHOLDER_STRING_MISSING
121
-    */
109
+    /**
110
+     * Replaces the placeholder at the location with the specified
111
+     * replacement text.
112
+     * 
113
+     * NOTE: The replacement text MUST contain the original placeholder
114
+     * for this to work. An exception will be triggered otherwise.
115
+     * 
116
+     * @param Mailcode_Parser_Safeguard_Placeholder_Locator_Location $location
117
+     * @param string $replacementText
118
+     * @throws Mailcode_Exception
119
+     * 
120
+     * @see Mailcode_Parser_Safeguard_Placeholder_Locator_Replacer::ERROR_PLACEHOLDER_STRING_MISSING
121
+     */
122 122
     public function replaceWith(Mailcode_Parser_Safeguard_Placeholder_Locator_Location $location, string $replacementText) : void
123 123
     {
124 124
         $replacer = new Mailcode_Parser_Safeguard_Placeholder_Locator_Replacer(
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
         $this->subject = $subject;
137 137
     }
138 138
     
139
-   /**
140
-    * Retrieves the subject string, with all changes that were made, if any. 
141
-    *  
142
-    * @return string
143
-    */
139
+    /**
140
+     * Retrieves the subject string, with all changes that were made, if any. 
141
+     *  
142
+     * @return string
143
+     */
144 144
     public function getSubjectString() : string
145 145
     {
146 146
         return $this->subject;
Please login to merge, or discard this patch.