Completed
Push — master ( 2a8174...85af9a )
by MeWebStudio - Muharrem
13s
created
src/PurifierServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $source = realpath(__DIR__.'/../config/purifier.php');
35 35
         if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
36
-            $this->publishes([$source => config_path('purifier.php')]);
36
+            $this->publishes([ $source => config_path('purifier.php') ]);
37 37
         } elseif ($this->app instanceof LumenApplication) {
38 38
             $this->app->configure('purifier');
39 39
         }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        $this->app->singleton('purifier', function (Container $app) {
52
-            return new Purifier($app['files'], $app['config']);
51
+        $this->app->singleton('purifier', function(Container $app) {
52
+            return new Purifier($app[ 'files' ], $app[ 'config' ]);
53 53
         });
54 54
 
55 55
         $this->app->alias('purifier', Purifier::class);
@@ -62,6 +62,6 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function provides()
64 64
     {
65
-        return ['purifier'];
65
+        return [ 'purifier' ];
66 66
     }
67 67
 }
Please login to merge, or discard this patch.
src/Purifier.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function setUp()
62 62
     {
63
-        if (!$this->config->has('purifier')) {
63
+        if ( ! $this->config->has('purifier')) {
64 64
             throw new Exception('Configuration parameters not loaded!');
65 65
         }
66 66
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $config = HTMLPurifier_Config::createDefault();
71 71
 
72 72
         // Allow configuration to be modified
73
-        if (!$this->config->get('purifier.finalize')) {
73
+        if ( ! $this->config->get('purifier.finalize')) {
74 74
             $config->autoFinalize = false;
75 75
         }
76 76
 
@@ -110,30 +110,30 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	private function addCustomDefinition(array $definitionConfig, $configObject = null)
112 112
 	{
113
-		if (!$configObject) {
113
+		if ( ! $configObject) {
114 114
 			$configObject = HTMLPurifier_Config::createDefault();
115 115
 			$configObject->loadArray($this->getConfig());
116 116
 		}
117 117
 		
118 118
 		// Setup the custom definition
119
-		$configObject->set('HTML.DefinitionID', $definitionConfig['id']);
120
-		$configObject->set('HTML.DefinitionRev', $definitionConfig['rev']);
119
+		$configObject->set('HTML.DefinitionID', $definitionConfig[ 'id' ]);
120
+		$configObject->set('HTML.DefinitionRev', $definitionConfig[ 'rev' ]);
121 121
 		
122 122
 		// Enable debug mode
123
-		if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) {
123
+		if ( ! isset($definitionConfig[ 'debug' ]) || $definitionConfig[ 'debug' ]) {
124 124
 			$configObject->set('Cache.DefinitionImpl', null);
125 125
 		}
126 126
 		
127 127
 		// Start configuring the definition
128 128
 		if ($def = $configObject->maybeGetRawHTMLDefinition()) {
129 129
 			// Create the definition attributes
130
-			if (!empty($definitionConfig['attributes'])) {
131
-				$this->addCustomAttributes($definitionConfig['attributes'], $def);
130
+			if ( ! empty($definitionConfig[ 'attributes' ])) {
131
+				$this->addCustomAttributes($definitionConfig[ 'attributes' ], $def);
132 132
 			}
133 133
 			
134 134
 			// Create the definition elements
135
-			if (!empty($definitionConfig['elements'])) {
136
-				$this->addCustomElements($definitionConfig['elements'], $def);
135
+			if ( ! empty($definitionConfig[ 'elements' ])) {
136
+				$this->addCustomElements($definitionConfig[ 'elements' ], $def);
137 137
 			}
138 138
 		}
139 139
 		
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	{
153 153
 		foreach ($attributes as $attribute) {
154 154
 			// Get configuration of attribute
155
-			$required = !empty($attribute[3]) ? true : false;
156
-			$onElement = $attribute[0];
157
-			$attrName = $required ? $attribute[1] . '*' : $attribute[1];
158
-			$validValues = $attribute[2];
155
+			$required = ! empty($attribute[ 3 ]) ? true : false;
156
+			$onElement = $attribute[ 0 ];
157
+			$attrName = $required ? $attribute[ 1 ].'*' : $attribute[ 1 ];
158
+			$validValues = $attribute[ 2 ];
159 159
 			
160 160
 			$definition->addAttribute($onElement, $attrName, $validValues);
161 161
 		}
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 	{
176 176
 		foreach ($elements as $element) {
177 177
 			// Get configuration of element
178
-			$name = $element[0];
179
-			$contentSet = $element[1];
180
-			$allowedChildren = $element[2];
181
-			$attributeCollection = $element[3];
182
-			$attributes = isset($element[4]) ? $element[4] : null;
178
+			$name = $element[ 0 ];
179
+			$contentSet = $element[ 1 ];
180
+			$allowedChildren = $element[ 2 ];
181
+			$attributeCollection = $element[ 3 ];
182
+			$attributes = isset($element[ 4 ]) ? $element[ 4 ] : null;
183 183
 			
184
-			if (!empty($attributes)) {
184
+			if ( ! empty($attributes)) {
185 185
 				$definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes);
186 186
 			} else {
187 187
 				$definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         $cachePath = $this->config->get('purifier.cachePath');
198 198
 
199 199
         if ($cachePath) {
200
-            if (!$this->files->isDirectory($cachePath)) {
200
+            if ( ! $this->files->isDirectory($cachePath)) {
201 201
                 $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755));
202 202
             }
203 203
         }
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
      */
221 221
     protected function getConfig($config = null)
222 222
     {
223
-        $default_config = [];
224
-        $default_config['Core.Encoding'] = $this->config->get('purifier.encoding');
225
-        $default_config['Cache.SerializerPath'] = $this->config->get('purifier.cachePath');
226
-        $default_config['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755);
223
+        $default_config = [ ];
224
+        $default_config[ 'Core.Encoding' ] = $this->config->get('purifier.encoding');
225
+        $default_config[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath');
226
+        $default_config[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755);
227 227
 
228
-        if (!$config) {
228
+        if ( ! $config) {
229 229
             $config = $this->config->get('purifier.settings.default');
230 230
         } elseif (is_string($config)) {
231 231
             $config = $this->config->get('purifier.settings.'.$config);
232 232
         }
233 233
 
234
-        if (!is_array($config)) {
235
-            $config = [];
234
+        if ( ! is_array($config)) {
235
+            $config = [ ];
236 236
         }
237 237
 
238 238
         $config = $default_config + $config;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     public function clean($dirty, $config = null)
250 250
     {
251 251
         if (is_array($dirty)) {
252
-            return array_map(function ($item) use ($config) {
252
+            return array_map(function($item) use ($config) {
253 253
                 return $this->clean($item, $config);
254 254
             }, $dirty);
255 255
         }
Please login to merge, or discard this patch.
config/purifier.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
             'debug' => false,
43 43
             'elements' => [
44 44
                 // http://developers.whatwg.org/sections.html
45
-                ['section', 'Block', 'Flow', 'Common'],
46
-                ['nav',     'Block', 'Flow', 'Common'],
47
-                ['article', 'Block', 'Flow', 'Common'],
48
-                ['aside',   'Block', 'Flow', 'Common'],
49
-                ['header',  'Block', 'Flow', 'Common'],
50
-                ['footer',  'Block', 'Flow', 'Common'],
45
+                [ 'section', 'Block', 'Flow', 'Common' ],
46
+                [ 'nav', 'Block', 'Flow', 'Common' ],
47
+                [ 'article', 'Block', 'Flow', 'Common' ],
48
+                [ 'aside', 'Block', 'Flow', 'Common' ],
49
+                [ 'header', 'Block', 'Flow', 'Common' ],
50
+                [ 'footer', 'Block', 'Flow', 'Common' ],
51 51
 				
52 52
 				// Content model actually excludes several tags, not modelled here
53
-                ['address', 'Block', 'Flow', 'Common'],
54
-                ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
53
+                [ 'address', 'Block', 'Flow', 'Common' ],
54
+                [ 'hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common' ],
55 55
 				
56 56
 				// http://developers.whatwg.org/grouping-content.html
57
-                ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
58
-                ['figcaption', 'Inline', 'Flow', 'Common'],
57
+                [ 'figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common' ],
58
+                [ 'figcaption', 'Inline', 'Flow', 'Common' ],
59 59
 				
60 60
 				// http://developers.whatwg.org/the-video-element.html#the-video-element
61
-                ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
61
+                [ 'video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
62 62
                     'src' => 'URI',
63 63
 					'type' => 'Text',
64 64
 					'width' => 'Length',
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 					'poster' => 'URI',
67 67
 					'preload' => 'Enum#auto,metadata,none',
68 68
 					'controls' => 'Bool',
69
-                ]],
70
-                ['source', 'Block', 'Flow', 'Common', [
69
+                ] ],
70
+                [ 'source', 'Block', 'Flow', 'Common', [
71 71
 					'src' => 'URI',
72 72
 					'type' => 'Text',
73
-                ]],
73
+                ] ],
74 74
 
75 75
 				// http://developers.whatwg.org/text-level-semantics.html
76
-                ['s',    'Inline', 'Inline', 'Common'],
77
-                ['var',  'Inline', 'Inline', 'Common'],
78
-                ['sub',  'Inline', 'Inline', 'Common'],
79
-                ['sup',  'Inline', 'Inline', 'Common'],
80
-                ['mark', 'Inline', 'Inline', 'Common'],
81
-                ['wbr',  'Inline', 'Empty', 'Core'],
76
+                [ 's', 'Inline', 'Inline', 'Common' ],
77
+                [ 'var', 'Inline', 'Inline', 'Common' ],
78
+                [ 'sub', 'Inline', 'Inline', 'Common' ],
79
+                [ 'sup', 'Inline', 'Inline', 'Common' ],
80
+                [ 'mark', 'Inline', 'Inline', 'Common' ],
81
+                [ 'wbr', 'Inline', 'Empty', 'Core' ],
82 82
 				
83 83
 				// http://developers.whatwg.org/edits.html
84
-                ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
85
-                ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
84
+                [ 'ins', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ],
85
+                [ 'del', 'Block', 'Flow', 'Common', [ 'cite' => 'URI', 'datetime' => 'CDATA' ] ],
86 86
             ],
87 87
             'attributes' => [
88
-                ['iframe', 'allowfullscreen', 'Bool'],
89
-                ['table', 'height', 'Text'],
90
-                ['td', 'border', 'Text'],
91
-                ['th', 'border', 'Text'],
92
-                ['tr', 'width', 'Text'],
93
-                ['tr', 'height', 'Text'],
94
-                ['tr', 'border', 'Text'],
88
+                [ 'iframe', 'allowfullscreen', 'Bool' ],
89
+                [ 'table', 'height', 'Text' ],
90
+                [ 'td', 'border', 'Text' ],
91
+                [ 'th', 'border', 'Text' ],
92
+                [ 'tr', 'width', 'Text' ],
93
+                [ 'tr', 'height', 'Text' ],
94
+                [ 'tr', 'border', 'Text' ],
95 95
             ],
96 96
         ],
97 97
         'custom_attributes' => [
98
-            ['a', 'target', 'Enum#_blank,_self,_target,_top'],
98
+            [ 'a', 'target', 'Enum#_blank,_self,_target,_top' ],
99 99
         ],
100 100
         'custom_elements' => [
101
-            ['u', 'Inline', 'Inline', 'Common'],
101
+            [ 'u', 'Inline', 'Inline', 'Common' ],
102 102
         ],
103 103
     ],
104 104
 
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!function_exists('clean')) {
3
+if ( ! function_exists('clean')) {
4 4
     function clean($dirty, $config = null)
5 5
     {
6 6
         return app('purifier')->clean($dirty, $config);
Please login to merge, or discard this patch.