@@ -8,61 +8,61 @@ |
||
8 | 8 | */ |
9 | 9 | class FilterHelper |
10 | 10 | { |
11 | - protected $filters = array(); |
|
12 | - protected $filterAutoLoad = true; |
|
11 | + protected $filters = array(); |
|
12 | + protected $filterAutoLoad = true; |
|
13 | 13 | |
14 | - public function __construct(array $filters, $filterAutoLoad) |
|
15 | - { |
|
16 | - $this->filters = $filters; |
|
17 | - $this->filterAutoLoad = $filterAutoLoad; |
|
18 | - } |
|
14 | + public function __construct(array $filters, $filterAutoLoad) |
|
15 | + { |
|
16 | + $this->filters = $filters; |
|
17 | + $this->filterAutoLoad = $filterAutoLoad; |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param $name |
|
22 | - * |
|
23 | - * @return bool |
|
24 | - */ |
|
25 | - public function hasFilter($name) |
|
26 | - { |
|
27 | - return !is_null($this->getFilter($name)); |
|
28 | - } |
|
20 | + /** |
|
21 | + * @param $name |
|
22 | + * |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | + public function hasFilter($name) |
|
26 | + { |
|
27 | + return !is_null($this->getFilter($name)); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param $name |
|
32 | - * |
|
33 | - * @return callable |
|
34 | - */ |
|
35 | - public function getFilter($name) |
|
36 | - { |
|
37 | - // Check that filter is registered |
|
38 | - if (array_key_exists($name, $this->filters)) { |
|
39 | - return $this->filters[$name]; |
|
40 | - } |
|
30 | + /** |
|
31 | + * @param $name |
|
32 | + * |
|
33 | + * @return callable |
|
34 | + */ |
|
35 | + public function getFilter($name) |
|
36 | + { |
|
37 | + // Check that filter is registered |
|
38 | + if (array_key_exists($name, $this->filters)) { |
|
39 | + return $this->filters[$name]; |
|
40 | + } |
|
41 | 41 | |
42 | - if (!$this->filterAutoLoad) { |
|
43 | - return; |
|
44 | - } |
|
42 | + if (!$this->filterAutoLoad) { |
|
43 | + return; |
|
44 | + } |
|
45 | 45 | |
46 | - // Else check if a class with a name that match can be loaded |
|
47 | - foreach (array('Pug', 'Jade') as $namespace) { |
|
48 | - $filter = $namespace . '\\Filter\\' . implode('', array_map('ucfirst', explode('-', $name))); |
|
49 | - if (class_exists($filter)) { |
|
50 | - return $filter; |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
46 | + // Else check if a class with a name that match can be loaded |
|
47 | + foreach (array('Pug', 'Jade') as $namespace) { |
|
48 | + $filter = $namespace . '\\Filter\\' . implode('', array_map('ucfirst', explode('-', $name))); |
|
49 | + if (class_exists($filter)) { |
|
50 | + return $filter; |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param $name |
|
57 | - * |
|
58 | - * @return callable |
|
59 | - */ |
|
60 | - public function getValidFilter($name) |
|
61 | - { |
|
62 | - if ($filter = $this->getFilter($name)) { |
|
63 | - return $filter; |
|
64 | - } |
|
55 | + /** |
|
56 | + * @param $name |
|
57 | + * |
|
58 | + * @return callable |
|
59 | + */ |
|
60 | + public function getValidFilter($name) |
|
61 | + { |
|
62 | + if ($filter = $this->getFilter($name)) { |
|
63 | + return $filter; |
|
64 | + } |
|
65 | 65 | |
66 | - throw new \InvalidArgumentException($name . ': Filter doesn\'t exists', 17); |
|
67 | - } |
|
66 | + throw new \InvalidArgumentException($name . ': Filter doesn\'t exists', 17); |
|
67 | + } |
|
68 | 68 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | // Else check if a class with a name that match can be loaded |
47 | 47 | foreach (array('Pug', 'Jade') as $namespace) { |
48 | - $filter = $namespace . '\\Filter\\' . implode('', array_map('ucfirst', explode('-', $name))); |
|
48 | + $filter = $namespace.'\\Filter\\'.implode('', array_map('ucfirst', explode('-', $name))); |
|
49 | 49 | if (class_exists($filter)) { |
50 | 50 | return $filter; |
51 | 51 | } |
@@ -63,6 +63,6 @@ discard block |
||
63 | 63 | return $filter; |
64 | 64 | } |
65 | 65 | |
66 | - throw new \InvalidArgumentException($name . ': Filter doesn\'t exists', 17); |
|
66 | + throw new \InvalidArgumentException($name.': Filter doesn\'t exists', 17); |
|
67 | 67 | } |
68 | 68 | } |
@@ -4,80 +4,80 @@ |
||
4 | 4 | |
5 | 5 | abstract class ValuesCompiler extends CompilerUtils |
6 | 6 | { |
7 | - /** |
|
8 | - * Value treatment if it must not be escaped. |
|
9 | - * |
|
10 | - * @param string input value |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - public static function getUnescapedValue($val) |
|
15 | - { |
|
16 | - if (is_null($val) || $val === false || $val === '') { |
|
17 | - return ''; |
|
18 | - } |
|
7 | + /** |
|
8 | + * Value treatment if it must not be escaped. |
|
9 | + * |
|
10 | + * @param string input value |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + public static function getUnescapedValue($val) |
|
15 | + { |
|
16 | + if (is_null($val) || $val === false || $val === '') { |
|
17 | + return ''; |
|
18 | + } |
|
19 | 19 | |
20 | - return is_array($val) || is_bool($val) || is_int($val) || is_float($val) ? json_encode($val) : strval($val); |
|
21 | - } |
|
20 | + return is_array($val) || is_bool($val) || is_int($val) || is_float($val) ? json_encode($val) : strval($val); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Value treatment if it must be escaped. |
|
25 | - * |
|
26 | - * @param string input value |
|
27 | - * |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public static function getEscapedValue($val, $quote) |
|
31 | - { |
|
32 | - $val = htmlspecialchars(static::getUnescapedValue($val), ENT_NOQUOTES); |
|
23 | + /** |
|
24 | + * Value treatment if it must be escaped. |
|
25 | + * |
|
26 | + * @param string input value |
|
27 | + * |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public static function getEscapedValue($val, $quote) |
|
31 | + { |
|
32 | + $val = htmlspecialchars(static::getUnescapedValue($val), ENT_NOQUOTES); |
|
33 | 33 | |
34 | - return str_replace($quote, $quote === '"' ? '"' : ''', $val); |
|
35 | - } |
|
34 | + return str_replace($quote, $quote === '"' ? '"' : ''', $val); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Convert style object to CSS string. |
|
39 | - * |
|
40 | - * @param mixed value to be computed into style. |
|
41 | - * |
|
42 | - * @return mixed |
|
43 | - */ |
|
44 | - public static function styleValue($val) |
|
45 | - { |
|
46 | - if (is_array($val) && !is_string(key($val))) { |
|
47 | - $val = implode(';', $val); |
|
48 | - } elseif (is_array($val) || is_object($val)) { |
|
49 | - $style = array(); |
|
50 | - foreach ($val as $key => $property) { |
|
51 | - $style[] = $key . ':' . $property; |
|
52 | - } |
|
37 | + /** |
|
38 | + * Convert style object to CSS string. |
|
39 | + * |
|
40 | + * @param mixed value to be computed into style. |
|
41 | + * |
|
42 | + * @return mixed |
|
43 | + */ |
|
44 | + public static function styleValue($val) |
|
45 | + { |
|
46 | + if (is_array($val) && !is_string(key($val))) { |
|
47 | + $val = implode(';', $val); |
|
48 | + } elseif (is_array($val) || is_object($val)) { |
|
49 | + $style = array(); |
|
50 | + foreach ($val as $key => $property) { |
|
51 | + $style[] = $key . ':' . $property; |
|
52 | + } |
|
53 | 53 | |
54 | - $val = implode(';', $style); |
|
55 | - } |
|
54 | + $val = implode(';', $style); |
|
55 | + } |
|
56 | 56 | |
57 | - return $val; |
|
58 | - } |
|
57 | + return $val; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Convert style object to CSS string and return PHP code to escape then display it. |
|
62 | - * |
|
63 | - * @param mixed value to be computed into style and escaped. |
|
64 | - * |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function getEscapedStyle($val, $quote) |
|
68 | - { |
|
69 | - return static::getEscapedValue(static::styleValue($val), $quote); |
|
70 | - } |
|
60 | + /** |
|
61 | + * Convert style object to CSS string and return PHP code to escape then display it. |
|
62 | + * |
|
63 | + * @param mixed value to be computed into style and escaped. |
|
64 | + * |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function getEscapedStyle($val, $quote) |
|
68 | + { |
|
69 | + return static::getEscapedValue(static::styleValue($val), $quote); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Convert style object to CSS string and return PHP code to display it. |
|
74 | - * |
|
75 | - * @param mixed value to be computed into style and stringified. |
|
76 | - * |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public static function getUnescapedStyle($val) |
|
80 | - { |
|
81 | - return static::getUnescapedValue(static::styleValue($val)); |
|
82 | - } |
|
72 | + /** |
|
73 | + * Convert style object to CSS string and return PHP code to display it. |
|
74 | + * |
|
75 | + * @param mixed value to be computed into style and stringified. |
|
76 | + * |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public static function getUnescapedStyle($val) |
|
80 | + { |
|
81 | + return static::getUnescapedValue(static::styleValue($val)); |
|
82 | + } |
|
83 | 83 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } elseif (is_array($val) || is_object($val)) { |
49 | 49 | $style = array(); |
50 | 50 | foreach ($val as $key => $property) { |
51 | - $style[] = $key . ':' . $property; |
|
51 | + $style[] = $key.':'.$property; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $val = implode(';', $style); |
@@ -10,14 +10,14 @@ |
||
10 | 10 | */ |
11 | 11 | class Javascript extends AbstractFilter |
12 | 12 | { |
13 | - /** |
|
14 | - * @param Filter $node |
|
15 | - * @param Compiler $compiler |
|
16 | - * |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function __invoke(Filter $node, Compiler $compiler) |
|
20 | - { |
|
21 | - return '<script type="text/javascript">' . $this->getNodeString($node, $compiler) . '</script>'; |
|
22 | - } |
|
13 | + /** |
|
14 | + * @param Filter $node |
|
15 | + * @param Compiler $compiler |
|
16 | + * |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function __invoke(Filter $node, Compiler $compiler) |
|
20 | + { |
|
21 | + return '<script type="text/javascript">' . $this->getNodeString($node, $compiler) . '</script>'; |
|
22 | + } |
|
23 | 23 | } |
@@ -18,6 +18,6 @@ |
||
18 | 18 | */ |
19 | 19 | public function __invoke(Filter $node, Compiler $compiler) |
20 | 20 | { |
21 | - return '<script type="text/javascript">' . $this->getNodeString($node, $compiler) . '</script>'; |
|
21 | + return '<script type="text/javascript">'.$this->getNodeString($node, $compiler).'</script>'; |
|
22 | 22 | } |
23 | 23 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | class Css extends AbstractFilter |
9 | 9 | { |
10 | - public function __invoke(Filter $node, Compiler $compiler) |
|
11 | - { |
|
12 | - return '<style type="text/css">' . $this->getNodeString($node, $compiler) . '</style>'; |
|
13 | - } |
|
10 | + public function __invoke(Filter $node, Compiler $compiler) |
|
11 | + { |
|
12 | + return '<style type="text/css">' . $this->getNodeString($node, $compiler) . '</style>'; |
|
13 | + } |
|
14 | 14 | } |
@@ -9,6 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | public function __invoke(Filter $node, Compiler $compiler) |
11 | 11 | { |
12 | - return '<style type="text/css">' . $this->getNodeString($node, $compiler) . '</style>'; |
|
12 | + return '<style type="text/css">'.$this->getNodeString($node, $compiler).'</style>'; |
|
13 | 13 | } |
14 | 14 | } |
@@ -10,5 +10,5 @@ |
||
10 | 10 | */ |
11 | 11 | interface FilterInterface |
12 | 12 | { |
13 | - public function __invoke(Filter $filter, Compiler $compiler); |
|
13 | + public function __invoke(Filter $filter, Compiler $compiler); |
|
14 | 14 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | class Escaped extends AbstractFilter |
9 | 9 | { |
10 | - public function __invoke(Filter $node, Compiler $compiler) |
|
11 | - { |
|
12 | - return htmlentities($this->getNodeString($node, $compiler)); |
|
13 | - } |
|
10 | + public function __invoke(Filter $node, Compiler $compiler) |
|
11 | + { |
|
12 | + return htmlentities($this->getNodeString($node, $compiler)); |
|
13 | + } |
|
14 | 14 | } |
@@ -7,5 +7,5 @@ |
||
7 | 7 | */ |
8 | 8 | class Script extends AbstractFilter |
9 | 9 | { |
10 | - protected $tag = 'script'; |
|
10 | + protected $tag = 'script'; |
|
11 | 11 | } |
@@ -7,10 +7,10 @@ |
||
7 | 7 | */ |
8 | 8 | class Pre extends AbstractFilter |
9 | 9 | { |
10 | - protected $tag = 'pre'; |
|
10 | + protected $tag = 'pre'; |
|
11 | 11 | |
12 | - public function parse($contents) |
|
13 | - { |
|
14 | - return htmlspecialchars(trim($contents)); |
|
15 | - } |
|
12 | + public function parse($contents) |
|
13 | + { |
|
14 | + return htmlspecialchars(trim($contents)); |
|
15 | + } |
|
16 | 16 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | class Cdata extends AbstractFilter |
9 | 9 | { |
10 | - public function __invoke(Filter $node, Compiler $compiler) |
|
11 | - { |
|
12 | - return "<![CDATA[\n" . $this->getNodeString($node, $compiler) . "\n]]>"; |
|
13 | - } |
|
10 | + public function __invoke(Filter $node, Compiler $compiler) |
|
11 | + { |
|
12 | + return "<![CDATA[\n" . $this->getNodeString($node, $compiler) . "\n]]>"; |
|
13 | + } |
|
14 | 14 | } |
@@ -9,6 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | public function __invoke(Filter $node, Compiler $compiler) |
11 | 11 | { |
12 | - return "<![CDATA[\n" . $this->getNodeString($node, $compiler) . "\n]]>"; |
|
12 | + return "<![CDATA[\n".$this->getNodeString($node, $compiler)."\n]]>"; |
|
13 | 13 | } |
14 | 14 | } |