Test Failed
Push — master ( 81711e...bf8774 )
by Sebastian
03:41
created
src/Mailcode.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Mailcode
28 28
 {
29
-   /**
30
-    * @var Mailcode_Parser|NULL
31
-    */
29
+    /**
30
+     * @var Mailcode_Parser|NULL
31
+     */
32 32
     protected $parser = null;
33 33
     
34
-   /**
35
-    * @var Mailcode_Commands|NULL
36
-    */
34
+    /**
35
+     * @var Mailcode_Commands|NULL
36
+     */
37 37
     protected $commands = null;
38 38
     
39
-   /**
40
-    * @var Mailcode_Variables|NULL
41
-    */
39
+    /**
40
+     * @var Mailcode_Variables|NULL
41
+     */
42 42
     protected $variables = null;
43 43
     
44
-   /**
45
-    * @var Mailcode_Translator|NULL
46
-    */
44
+    /**
45
+     * @var Mailcode_Translator|NULL
46
+     */
47 47
     protected $translator = null;
48 48
     
49
-   /**
50
-    * Creates a new mailcode instance.
51
-    * @return Mailcode
52
-    */
49
+    /**
50
+     * Creates a new mailcode instance.
51
+     * @return Mailcode
52
+     */
53 53
     public static function create() : Mailcode
54 54
     {
55 55
         return new Mailcode();
56 56
     }
57 57
     
58
-   /**
59
-    * Parses the string to detect all commands contained within.
60
-    * 
61
-    * @param string $string
62
-    * @return Mailcode_Collection
63
-    */
58
+    /**
59
+     * Parses the string to detect all commands contained within.
60
+     * 
61
+     * @param string $string
62
+     * @return Mailcode_Collection
63
+     */
64 64
     public function parseString(string $string) : Mailcode_Collection
65 65
     {
66 66
         return $this->getParser()->parseString($string);
67 67
     }
68 68
     
69
-   /**
70
-    * Retrieves the string parser instance used to detect commands.
71
-    * 
72
-    * @return Mailcode_Parser
73
-    */
69
+    /**
70
+     * Retrieves the string parser instance used to detect commands.
71
+     * 
72
+     * @return Mailcode_Parser
73
+     */
74 74
     public function getParser() : Mailcode_Parser
75 75
     {
76 76
         if(!isset($this->parser)) 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         return $this->parser;
82 82
     }
83 83
     
84
-   /**
85
-    * Retrieves the commands collection, which is used to
86
-    * access information on the available commands.
87
-    * 
88
-    * @return Mailcode_Commands
89
-    */
84
+    /**
85
+     * Retrieves the commands collection, which is used to
86
+     * access information on the available commands.
87
+     * 
88
+     * @return Mailcode_Commands
89
+     */
90 90
     public function getCommands() : Mailcode_Commands
91 91
     {
92 92
         if(!isset($this->commands)) 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
         return new Mailcode_StringContainer($subject);
108 108
     }
109 109
     
110
-   /**
111
-    * Attempts to find all variables in the target string.
112
-    * 
113
-    * @param string $subject
114
-    * @return Mailcode_Variables_Collection_Regular
115
-    */
110
+    /**
111
+     * Attempts to find all variables in the target string.
112
+     * 
113
+     * @param string $subject
114
+     * @return Mailcode_Variables_Collection_Regular
115
+     */
116 116
     public function findVariables(string $subject) : Mailcode_Variables_Collection_Regular
117 117
     {
118 118
         return $this->createVariables()->parseString($subject);
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
         return $this->variables;
129 129
     }
130 130
     
131
-   /**
132
-    * Creates the translator, which can be used to convert commands
133
-    * to another supported syntax.
134
-    * 
135
-    * @return Mailcode_Translator
136
-    */
131
+    /**
132
+     * Creates the translator, which can be used to convert commands
133
+     * to another supported syntax.
134
+     * 
135
+     * @return Mailcode_Translator
136
+     */
137 137
     public function createTranslator() : Mailcode_Translator
138 138
     {
139 139
         if(!isset($this->translator))
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
         return $this->translator;
145 145
     }
146 146
     
147
-   /**
148
-    * Creates the styler, which can be used to retrieve the 
149
-    * CSS required to style the highlighted commands in HTML.
150
-    * 
151
-    * @return Mailcode_Styler
152
-    */
147
+    /**
148
+     * Creates the styler, which can be used to retrieve the 
149
+     * CSS required to style the highlighted commands in HTML.
150
+     * 
151
+     * @return Mailcode_Styler
152
+     */
153 153
     public function createStyler() : Mailcode_Styler
154 154
     {
155 155
         return new Mailcode_Styler();
Please login to merge, or discard this patch.
src/Mailcode/Traits/Formatting/HTMLHighlighting.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
         'script'
32 32
     );
33 33
     
34
-   /**
35
-    * Adds an HTML tag name to the list of tags within which
36
-    * commands may not be highlighted.
37
-    *
38
-    * @param string $tagName Case insensitive.
39
-    * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
40
-    */
34
+    /**
35
+     * Adds an HTML tag name to the list of tags within which
36
+     * commands may not be highlighted.
37
+     *
38
+     * @param string $tagName Case insensitive.
39
+     * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
40
+     */
41 41
     public function excludeTag(string $tagName) : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
42 42
     {
43 43
         $tagName = strtolower($tagName);
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
         return $this;
51 51
     }
52 52
     
53
-   /**
54
-    * Adds several exluded tag names at once.
55
-    *
56
-    * @param string[] $tagNames
57
-    * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
58
-    */
53
+    /**
54
+     * Adds several exluded tag names at once.
55
+     *
56
+     * @param string[] $tagNames
57
+     * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
58
+     */
59 59
     public function excludeTags(array $tagNames) : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
60 60
     {
61 61
         foreach($tagNames as $tagName)
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
         return $this;
67 67
     }
68 68
     
69
-   /**
70
-    * Whether the specified tag name is in the exlusion list.
71
-    *
72
-    * @param string $tagName
73
-    * @return bool
74
-    */
69
+    /**
70
+     * Whether the specified tag name is in the exlusion list.
71
+     *
72
+     * @param string $tagName
73
+     * @return bool
74
+     */
75 75
     public function isTagExcluded(string $tagName) : bool
76 76
     {
77 77
         $tagName = strtolower($tagName);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $tagName = strtolower($tagName);
44 44
         
45
-        if(!in_array($tagName, $this->excludeTags))
45
+        if (!in_array($tagName, $this->excludeTags))
46 46
         {
47 47
             $this->excludeTags[] = $tagName;
48 48
         }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     */
59 59
     public function excludeTags(array $tagNames) : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
60 60
     {
61
-        foreach($tagNames as $tagName)
61
+        foreach ($tagNames as $tagName)
62 62
         {
63 63
             $this->excludeTag((string)$tagName);
64 64
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/ReplacerType.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@
 block discarded – undo
35 35
         }
36 36
     }
37 37
     
38
-   /**
39
-    * Resolves the string with which this location needs to be
40
-    * replaced.
41
-    * 
42
-    * @param Mailcode_Parser_Safeguard_Formatter_Location $location
43
-    * @return string
44
-    */
38
+    /**
39
+     * Resolves the string with which this location needs to be
40
+     * replaced.
41
+     * 
42
+     * @param Mailcode_Parser_Safeguard_Formatter_Location $location
43
+     * @return string
44
+     */
45 45
     private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string
46 46
     {
47 47
         if($location->requiresAdjustment())
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $locations = $this->resolveLocations();
31 31
         
32
-        foreach($locations as $location)
32
+        foreach ($locations as $location)
33 33
         {
34 34
             $location->replaceWith($this->resolveReplacement($location));
35 35
         }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     */
45 45
     private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string
46 46
     {
47
-        if($location->requiresAdjustment())
47
+        if ($location->requiresAdjustment())
48 48
         {
49 49
             return $this->getReplaceString($location);
50 50
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/SingleLines.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
  */
24 24
 class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines extends Mailcode_Parser_Safeguard_Formatter_FormatType
25 25
 {
26
-   /**
27
-    * @var string
28
-    */
26
+    /**
27
+     * @var string
28
+     */
29 29
     private $eol;
30 30
     
31
-   /**
32
-    * @var int
33
-    */
31
+    /**
32
+     * @var int
33
+     */
34 34
     private $eolLength;
35 35
     
36 36
     protected function initFormatting() : void
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/SingleLines/Location.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
  */
26 26
 class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines_Location extends Mailcode_Parser_Safeguard_Formatter_Location
27 27
 {
28
-   /**
29
-    * @var int
30
-    */
28
+    /**
29
+     * @var int
30
+     */
31 31
     protected $eolLength;
32 32
     
33
-   /**
34
-    * @var string
35
-    */
33
+    /**
34
+     * @var string
35
+     */
36 36
     protected $eol;
37 37
     
38 38
     protected function init() : void
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,26 +54,26 @@  discard block
 block discarded – undo
54 54
         $position = $this->getStartPosition();
55 55
         
56 56
         // we're at the beginning of the string
57
-        if($position === false || $position === 0)
57
+        if ($position === false || $position === 0)
58 58
         {
59 59
             return;
60 60
         }
61 61
         
62 62
         $prevPos = $position - $this->eolLength;
63 63
         
64
-        if($prevPos < 0)
64
+        if ($prevPos < 0)
65 65
         {
66 66
             $prevPos = 0;
67 67
         }
68 68
         
69
-        if($this->isWithinCommand($prevPos))
69
+        if ($this->isWithinCommand($prevPos))
70 70
         {
71 71
             return;
72 72
         }
73 73
         
74 74
         $prev = $this->subject->getSubstr($prevPos, $this->eolLength);
75 75
         
76
-        if($prev !== $this->formatter->getEOLChar())
76
+        if ($prev !== $this->formatter->getEOLChar())
77 77
         {
78 78
             $this->prepend = $this->eol;
79 79
         }
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
         $position = $this->getEndPosition();
87 87
         
88 88
         // we're at the end of the string
89
-        if($position === false || $position >= $subjectLength)
89
+        if ($position === false || $position >= $subjectLength)
90 90
         {
91 91
             return;
92 92
         }
93 93
         
94 94
         $nextPos = $position + $this->eolLength;
95 95
         
96
-        if($nextPos > $subjectLength)
96
+        if ($nextPos > $subjectLength)
97 97
         {
98 98
             $nextPos = $subjectLength - $this->eolLength;
99 99
         }
100 100
         
101 101
         $next = $this->subject->getSubstr($nextPos, $this->eolLength);
102 102
         
103
-        if($next !== $this->formatter->getEOLChar())
103
+        if ($next !== $this->formatter->getEOLChar())
104 104
         {
105 105
             $this->append = $this->eol;
106 106
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/MarkVariables/Location.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     
33 33
     public function requiresAdjustment(): bool
34 34
     {
35
-        if(!parent::requiresAdjustment())
35
+        if (!parent::requiresAdjustment())
36 36
         {
37 37
             return false;
38 38
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/HTMLHighlighting/Location.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
 {
25 25
     const COMMAND_MARKER = '__MAILCODE_COMMAND__';
26 26
     
27
-   /**
28
-    * @var boolean
29
-    */
27
+    /**
28
+     * @var boolean
29
+     */
30 30
     private $ancestryChecked = false;
31 31
     
32
-   /**
33
-    * @var array<int,array<int,string>>
34
-    */
32
+    /**
33
+     * @var array<int,array<int,string>>
34
+     */
35 35
     private $tagAncestry = array();
36 36
     
37 37
     protected function init() : void
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         return !$this->isInTagAttributes() && !$this->isInExcludedTag();
44 44
     }
45 45
     
46
-   /**
47
-    * Retrieves the part of the subject string that comes
48
-    * before the command.
49
-    * 
50
-    * @return string
51
-    */
46
+    /**
47
+     * Retrieves the part of the subject string that comes
48
+     * before the command.
49
+     * 
50
+     * @return string
51
+     */
52 52
     private function getHaystackBefore() : string
53 53
     {
54 54
         $pos = $this->getStartPosition();
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
         return $this->subject->getSubstr(0, $pos).self::COMMAND_MARKER.'>';
66 66
     }
67 67
     
68
-   /**
69
-    * Whether the command is nested in one of the tags
70
-    * that have been added to the list of excluded tags.
71
-    * 
72
-    * @return bool
73
-    */
68
+    /**
69
+     * Whether the command is nested in one of the tags
70
+     * that have been added to the list of excluded tags.
71
+     * 
72
+     * @return bool
73
+     */
74 74
     protected function isInExcludedTag() : bool
75 75
     {
76 76
         $tagNames = $this->getParentTags();
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
         return false;
87 87
     }
88 88
     
89
-   /**
90
-    * Retrieves a list of the command's parent HTML tags, from
91
-    * highest to lowest.
92
-    * 
93
-    * @return string[]
94
-    */
89
+    /**
90
+     * Retrieves a list of the command's parent HTML tags, from
91
+     * highest to lowest.
92
+     * 
93
+     * @return string[]
94
+     */
95 95
     private function getParentTags() : array
96 96
     {
97 97
         $tags = $this->getTagAncestry();
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
         return $stack;
117 117
     }
118 118
     
119
-   /**
120
-    * Checks whether the command is located within the attributes
121
-    * of an HTML tag.
122
-    * 
123
-    * @return bool
124
-    */
119
+    /**
120
+     * Checks whether the command is located within the attributes
121
+     * of an HTML tag.
122
+     * 
123
+     * @return bool
124
+     */
125 125
     protected function isInTagAttributes() : bool
126 126
     {
127 127
         $tags = $this->getTagAncestry();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $pos = $this->getStartPosition();
55 55
         
56
-        if(is_bool($pos))
56
+        if (is_bool($pos))
57 57
         {
58 58
             return '';
59 59
         }
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $tagNames = $this->getParentTags();
77 77
         
78
-        foreach($tagNames as $tagName)
78
+        foreach ($tagNames as $tagName)
79 79
         {
80
-            if($this->formatter->isTagExcluded($tagName))
80
+            if ($this->formatter->isTagExcluded($tagName))
81 81
             {
82 82
                 return true;
83 83
             }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         // Create a stack of all direct parent tags of the command.
100 100
         // Handles closing tags as well.
101 101
         $stack = array();
102
-        foreach($tags[2] as $idx => $tagName)
102
+        foreach ($tags[2] as $idx => $tagName)
103 103
         {
104 104
             $closing = $tags[1][$idx] === '/';
105 105
             
106
-            if($closing)
106
+            if ($closing)
107 107
             {
108 108
                 array_pop($stack);
109 109
             }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
         
129 129
         // This check is easy: if the command is in the attribute
130 130
         // of any of the tags, we will find the command marker in there.
131
-        foreach($tags[3] as $attributes)
131
+        foreach ($tags[3] as $attributes)
132 132
         {
133
-            if(strstr($attributes, self::COMMAND_MARKER))
133
+            if (strstr($attributes, self::COMMAND_MARKER))
134 134
             {
135 135
                 return true;
136 136
             }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     
142 142
     private function getTagAncestry() : array
143 143
     {
144
-        if($this->ancestryChecked)
144
+        if ($this->ancestryChecked)
145 145
         {
146 146
             return $this->tagAncestry;
147 147
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/MarkVariables.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
     
30 30
     const ERROR_INVALID_TAG_TEMPLATE = 66101;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     private $tagTemplate = '<span class="mailcode-marked-variable">%s</span>';
36 36
     
37 37
     protected function initFormatting() : void
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     
41 41
     public function setTemplate(string $template) : void
42 42
     {
43
-        if(substr_count($template, '%s') !== 1)
43
+        if (substr_count($template, '%s') !== 1)
44 44
         {
45 45
             throw new Mailcode_Exception(
46 46
                 'Invalid tag template',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/FormatType.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
         return PHP_INT_MAX;
26 26
     }
27 27
 
28
-   /**
29
-    * Formats the specified string according to the formatter.
30
-    * Retrieve the updated string from the string container used
31
-    * to create the formatter, or use `getSubjectString()`.
32
-    */
28
+    /**
29
+     * Formats the specified string according to the formatter.
30
+     * Retrieve the updated string from the string container used
31
+     * to create the formatter, or use `getSubjectString()`.
32
+     */
33 33
     public function format() : void
34 34
     {
35 35
         $locations = $this->resolveLocations();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     {
35 35
         $locations = $this->resolveLocations();
36 36
         
37
-        foreach($locations as $location)
37
+        foreach ($locations as $location)
38 38
         {
39 39
             $location->format();
40 40
         }
Please login to merge, or discard this patch.