@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class Mailcode_Renderer |
23 | 23 | { |
24 | - /** |
|
25 | - * @var boolean |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var boolean |
|
26 | + */ |
|
27 | 27 | protected $highlighted = false; |
28 | 28 | |
29 | - /** |
|
30 | - * Sets whether to output highlighted commands instead of the default plain text. |
|
31 | - * |
|
32 | - * @param bool $highlighted |
|
33 | - * @return Mailcode_Renderer |
|
34 | - */ |
|
29 | + /** |
|
30 | + * Sets whether to output highlighted commands instead of the default plain text. |
|
31 | + * |
|
32 | + * @param bool $highlighted |
|
33 | + * @return Mailcode_Renderer |
|
34 | + */ |
|
35 | 35 | public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
36 | 36 | { |
37 | 37 | $this->highlighted = $highlighted; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * Converts a show variable command to string. |
|
44 | - * |
|
45 | - * @param string $variableName The variable name, with or without $ sign. |
|
46 | - * @return string |
|
47 | - */ |
|
42 | + /** |
|
43 | + * Converts a show variable command to string. |
|
44 | + * |
|
45 | + * @param string $variableName The variable name, with or without $ sign. |
|
46 | + * @return string |
|
47 | + */ |
|
48 | 48 | public function showVar(string $variableName) : string |
49 | 49 | { |
50 | 50 | return $this->command2string(Mailcode_Factory::showVar($variableName)); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param bool $highlighted |
33 | 33 | * @return Mailcode_Renderer |
34 | 34 | */ |
35 | - public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
|
35 | + public function setOutputHighlighted(bool $highlighted = true) : Mailcode_Renderer |
|
36 | 36 | { |
37 | 37 | $this->highlighted = $highlighted; |
38 | 38 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | return $this->command2string(Mailcode_Factory::setVarString($variableName, $value)); |
61 | 61 | } |
62 | 62 | |
63 | - public function if(string $condition, string $type='') : string |
|
63 | + public function if (string $condition, string $type = '') : string |
|
64 | 64 | { |
65 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
65 | + return $this->command2string(Mailcode_Factory::if ($condition, $type)); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function ifVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | return $this->command2string(Mailcode_Factory::ifVarNotEqualsString($variable, $value)); |
96 | 96 | } |
97 | 97 | |
98 | - public function elseIf(string $condition, string $type='') : string |
|
98 | + public function elseIf (string $condition, string $type = '') : string |
|
99 | 99 | { |
100 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
100 | + return $this->command2string(Mailcode_Factory::elseIf ($condition, $type)); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | protected function command2string(Mailcode_Commands_Command $command) : string |
149 | 149 | { |
150 | - if($this->highlighted) |
|
150 | + if ($this->highlighted) |
|
151 | 151 | { |
152 | 152 | return $command->getHighlighted(); |
153 | 153 | } |
@@ -62,7 +62,9 @@ discard block |
||
62 | 62 | |
63 | 63 | public function if(string $condition, string $type='') : string |
64 | 64 | { |
65 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
65 | + return $this->command2string(Mailcode_Factory::if($condition, $type) { |
|
66 | + ); |
|
67 | + } |
|
66 | 68 | } |
67 | 69 | |
68 | 70 | public function ifVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -97,7 +99,9 @@ discard block |
||
97 | 99 | |
98 | 100 | public function elseIf(string $condition, string $type='') : string |
99 | 101 | { |
100 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
102 | + return $this->command2string(Mailcode_Factory::elseIf($condition, $type) { |
|
103 | + ); |
|
104 | + } |
|
101 | 105 | } |
102 | 106 | |
103 | 107 | public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -130,10 +134,12 @@ discard block |
||
130 | 134 | return $this->command2string(Mailcode_Factory::elseIfVarNotEqualsString($variable, $value)); |
131 | 135 | } |
132 | 136 | |
133 | - public function else() : string |
|
137 | + public function else { |
|
138 | + () : string |
|
134 | 139 | { |
135 | 140 | return $this->command2string(Mailcode_Factory::else()); |
136 | 141 | } |
142 | + } |
|
137 | 143 | |
138 | 144 | public function end() : string |
139 | 145 | { |
@@ -22,17 +22,17 @@ |
||
22 | 22 | { |
23 | 23 | const REGEX_VARIABLE_NAME = '/\$\s*([A-Z0-9_]+)\s*\.\s*([A-Z0-9_]+)|\$\s*([A-Z0-9_]+)/six'; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Mailcode_Variables_Collection_Regular |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Mailcode_Variables_Collection_Regular |
|
27 | + */ |
|
28 | 28 | protected $collection; |
29 | 29 | |
30 | - /** |
|
31 | - * Parses the specified string to find all variable names contained within, if any. |
|
32 | - * |
|
33 | - * @param string $subject |
|
34 | - * @return Mailcode_Variables_Collection_Regular |
|
35 | - */ |
|
30 | + /** |
|
31 | + * Parses the specified string to find all variable names contained within, if any. |
|
32 | + * |
|
33 | + * @param string $subject |
|
34 | + * @return Mailcode_Variables_Collection_Regular |
|
35 | + */ |
|
36 | 36 | public function parseString(string $subject) : Mailcode_Variables_Collection_Regular |
37 | 37 | { |
38 | 38 | $this->collection = new Mailcode_Variables_Collection_Regular(); |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | $matches = array(); |
41 | 41 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
42 | 42 | |
43 | - if(!isset($matches[0]) || empty($matches[0])) |
|
43 | + if (!isset($matches[0]) || empty($matches[0])) |
|
44 | 44 | { |
45 | 45 | return $this->collection; |
46 | 46 | } |
47 | 47 | |
48 | - foreach($matches[0] as $idx => $matchedText) |
|
48 | + foreach ($matches[0] as $idx => $matchedText) |
|
49 | 49 | { |
50 | - if(!empty($matches[3][$idx])) |
|
50 | + if (!empty($matches[3][$idx])) |
|
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function addSingle(string $name, string $matchedText) : void |
64 | 64 | { |
65 | 65 | // ignore US style numbers like $451 |
66 | - if(is_numeric($name)) |
|
66 | + if (is_numeric($name)) |
|
67 | 67 | { |
68 | 68 | return; |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function addPathed(string $path, string $name, string $matchedText) : void |
75 | 75 | { |
76 | 76 | // ignore US style numbers like $45.12 |
77 | - if(is_numeric($path.'.'.$name)) |
|
77 | + if (is_numeric($path.'.'.$name)) |
|
78 | 78 | { |
79 | 79 | return; |
80 | 80 | } |
@@ -50,8 +50,7 @@ |
||
50 | 50 | if(!empty($matches[3][$idx])) |
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | - } |
|
54 | - else |
|
53 | + } else |
|
55 | 54 | { |
56 | 55 | $this->addPathed($matches[1][$idx], $matches[2][$idx], $matchedText); |
57 | 56 | } |