Completed
Pull Request — master (#129)
by tsugumu
10:48
created
src/Purifier.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     private function setUp()
63 63
     {
64
-        if (!$this->config->has('purifier')) {
64
+        if ( ! $this->config->has('purifier')) {
65 65
             throw new Exception('Configuration parameters not loaded!');
66 66
         }
67 67
 
@@ -85,30 +85,30 @@  discard block
 block discarded – undo
85 85
      */
86 86
     private function addCustomDefinition(array $definitionConfig, HTMLPurifier_Config $configObject = null)
87 87
     {
88
-        if (!$configObject) {
88
+        if ( ! $configObject) {
89 89
             $configObject = HTMLPurifier_Config::createDefault();
90 90
             $configObject->loadArray($this->getConfig());
91 91
         }
92 92
 
93 93
         // Setup the custom definition
94
-        $configObject->set('HTML.DefinitionID', $definitionConfig['id']);
95
-        $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']);
94
+        $configObject->set('HTML.DefinitionID', $definitionConfig[ 'id' ]);
95
+        $configObject->set('HTML.DefinitionRev', $definitionConfig[ 'rev' ]);
96 96
 
97 97
         // Enable debug mode
98
-        if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) {
98
+        if ( ! isset($definitionConfig[ 'debug' ]) || $definitionConfig[ 'debug' ]) {
99 99
             $configObject->set('Cache.DefinitionImpl', null);
100 100
         }
101 101
 
102 102
         // Start configuring the definition
103 103
         if ($def = $configObject->maybeGetRawHTMLDefinition()) {
104 104
             // Create the definition attributes
105
-            if (!empty($definitionConfig['attributes'])) {
106
-                $this->addCustomAttributes($definitionConfig['attributes'], $def);
105
+            if ( ! empty($definitionConfig[ 'attributes' ])) {
106
+                $this->addCustomAttributes($definitionConfig[ 'attributes' ], $def);
107 107
             }
108 108
 
109 109
             // Create the definition elements
110
-            if (!empty($definitionConfig['elements'])) {
111
-                $this->addCustomElements($definitionConfig['elements'], $def);
110
+            if ( ! empty($definitionConfig[ 'elements' ])) {
111
+                $this->addCustomElements($definitionConfig[ 'elements' ], $def);
112 112
             }
113 113
         }
114 114
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
     {
128 128
         foreach ($attributes as $attribute) {
129 129
             // Get configuration of attribute
130
-            $required = !empty($attribute[3]) ? true : false;
131
-            $onElement = $attribute[0];
132
-            $attrName = $required ? $attribute[1] . '*' : $attribute[1];
133
-            $validValues = $attribute[2];
130
+            $required = ! empty($attribute[ 3 ]) ? true : false;
131
+            $onElement = $attribute[ 0 ];
132
+            $attrName = $required ? $attribute[ 1 ].'*' : $attribute[ 1 ];
133
+            $validValues = $attribute[ 2 ];
134 134
 
135 135
             $definition->addAttribute($onElement, $attrName, $validValues);
136 136
         }
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
     {
151 151
         foreach ($elements as $element) {
152 152
             // Get configuration of element
153
-            $name = $element[0];
154
-            $contentSet = $element[1];
155
-            $allowedChildren = $element[2];
156
-            $attributeCollection = $element[3];
157
-            $attributes = isset($element[4]) ? $element[4] : null;
153
+            $name = $element[ 0 ];
154
+            $contentSet = $element[ 1 ];
155
+            $allowedChildren = $element[ 2 ];
156
+            $attributeCollection = $element[ 3 ];
157
+            $attributes = isset($element[ 4 ]) ? $element[ 4 ] : null;
158 158
 
159
-            if (!empty($attributes)) {
159
+            if ( ! empty($attributes)) {
160 160
                 $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes);
161 161
             } else {
162 162
                 $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection);
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
         $cachePath = $this->config->get('purifier.cachePath');
173 173
 
174 174
         if ($cachePath) {
175
-            if (!$this->files->isDirectory($cachePath)) {
176
-                $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755),true);
175
+            if ( ! $this->files->isDirectory($cachePath)) {
176
+                $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755), true);
177 177
             }
178 178
         }
179 179
     }
@@ -189,24 +189,24 @@  discard block
 block discarded – undo
189 189
         $configObject = HTMLPurifier_Config::createDefault();
190 190
 
191 191
         // Allow configuration to be modified
192
-        if (! $this->config->get('purifier.finalize')) {
192
+        if ( ! $this->config->get('purifier.finalize')) {
193 193
             $configObject->autoFinalize = false;
194 194
         }
195 195
 
196 196
         // Set default config
197
-        $defaultConfig = [];
198
-        $defaultConfig['Core.Encoding'] = $this->config->get('purifier.encoding');
199
-        $defaultConfig['Cache.SerializerPath'] = $this->config->get('purifier.cachePath');
200
-        $defaultConfig['Cache.SerializerPermissions'] = $this->config->get('purifier.cacheFileMode', 0755);
197
+        $defaultConfig = [ ];
198
+        $defaultConfig[ 'Core.Encoding' ] = $this->config->get('purifier.encoding');
199
+        $defaultConfig[ 'Cache.SerializerPath' ] = $this->config->get('purifier.cachePath');
200
+        $defaultConfig[ 'Cache.SerializerPermissions' ] = $this->config->get('purifier.cacheFileMode', 0755);
201 201
 
202
-        if (! $config) {
202
+        if ( ! $config) {
203 203
             $config = $this->config->get('purifier.settings.default');
204 204
         } elseif (is_string($config)) {
205
-            $config = $this->config->get('purifier.settings.' . $config);
205
+            $config = $this->config->get('purifier.settings.'.$config);
206 206
         }
207 207
 
208
-        if (! is_array($config)) {
209
-            $config = [];
208
+        if ( ! is_array($config)) {
209
+            $config = [ ];
210 210
         }
211 211
 
212 212
         // Merge configurations
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     public function clean($dirty, $config = null, \Closure $postCreateConfigHook = null)
247 247
     {
248 248
         if (is_array($dirty)) {
249
-            return array_map(function ($item) use ($config) {
249
+            return array_map(function($item) use ($config) {
250 250
                 return $this->clean($item, $config);
251 251
             }, $dirty);
252 252
         }
Please login to merge, or discard this patch.