@@ -49,7 +49,7 @@  | 
                                                    ||
| 49 | 49 | /**  | 
                                                        
| 50 | 50 | * Get the services provided by the provider.  | 
                                                        
| 51 | 51 | *  | 
                                                        
| 52 | - * @return array  | 
                                                        |
| 52 | + * @return string[]  | 
                                                        |
| 53 | 53 | */  | 
                                                        
| 54 | 54 | public function provides()  | 
                                                        
| 55 | 55 |      { | 
                                                        
@@ -33,7 +33,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 62 | 62 | */  | 
                                                        
| 63 | 63 | public function provides()  | 
                                                        
| 64 | 64 |      { | 
                                                        
| 65 | - return ['purifier'];  | 
                                                        |
| 65 | + return [ 'purifier' ];  | 
                                                        |
| 66 | 66 | }  | 
                                                        
| 67 | 67 | }  | 
                                                        
@@ -78,21 +78,21 @@ discard block  | 
                                                    ||
| 78 | 78 | |
| 79 | 79 | // Load custom definition if set  | 
                                                        
| 80 | 80 |          if ($definitionConfig = $this->config->get('purifier.settings.custom_definition')) { | 
                                                        
| 81 | - $this->addCustomDefinition($definitionConfig, $config);  | 
                                                        |
| 81 | + $this->addCustomDefinition($definitionConfig, $config);  | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | 83 | |
| 84 | 84 | // Load custom elements if set  | 
                                                        
| 85 | 85 |          if ($elements = $this->config->get('purifier.settings.custom_elements')) { | 
                                                        
| 86 | -	        if ($def = $config->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 87 | - $this->addCustomElements($elements, $def);  | 
                                                        |
| 88 | - }  | 
                                                        |
| 86 | +            if ($def = $config->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 87 | + $this->addCustomElements($elements, $def);  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
| 91 | 91 | // Load custom attributes if set  | 
                                                        
| 92 | 92 |          if ($attributes = $this->config->get('purifier.settings.custom_attributes')) { | 
                                                        
| 93 | -	        if ($def = $config->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 94 | - $this->addCustomAttributes($attributes, $def);  | 
                                                        |
| 95 | - }  | 
                                                        |
| 93 | +            if ($def = $config->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 94 | + $this->addCustomAttributes($attributes, $def);  | 
                                                        |
| 95 | + }  | 
                                                        |
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
| 98 | 98 | // Create HTMLPurifier object  | 
                                                        
@@ -100,94 +100,94 @@ discard block  | 
                                                    ||
| 100 | 100 | }  | 
                                                        
| 101 | 101 | |
| 102 | 102 | /**  | 
                                                        
| 103 | - * Add a custom definition  | 
                                                        |
| 104 | - *  | 
                                                        |
| 105 | - * @see http://htmlpurifier.org/docs/enduser-customize.html  | 
                                                        |
| 106 | - * @param array $definitionConfig  | 
                                                        |
| 107 | - * @param HTML_Purifier_Config $configObject Defaults to using default config  | 
                                                        |
| 108 | - *  | 
                                                        |
| 109 | - * @return HTML_Purifier_Config $configObject  | 
                                                        |
| 110 | - */  | 
                                                        |
| 111 | - private function addCustomDefinition(array $definitionConfig, $configObject = null)  | 
                                                        |
| 112 | -	{ | 
                                                        |
| 113 | -		if (!$configObject) { | 
                                                        |
| 114 | - $configObject = HTMLPurifier_Config::createDefault();  | 
                                                        |
| 115 | - $configObject->loadArray($this->getConfig());  | 
                                                        |
| 116 | - }  | 
                                                        |
| 103 | + * Add a custom definition  | 
                                                        |
| 104 | + *  | 
                                                        |
| 105 | + * @see http://htmlpurifier.org/docs/enduser-customize.html  | 
                                                        |
| 106 | + * @param array $definitionConfig  | 
                                                        |
| 107 | + * @param HTML_Purifier_Config $configObject Defaults to using default config  | 
                                                        |
| 108 | + *  | 
                                                        |
| 109 | + * @return HTML_Purifier_Config $configObject  | 
                                                        |
| 110 | + */  | 
                                                        |
| 111 | + private function addCustomDefinition(array $definitionConfig, $configObject = null)  | 
                                                        |
| 112 | +    { | 
                                                        |
| 113 | +        if (!$configObject) { | 
                                                        |
| 114 | + $configObject = HTMLPurifier_Config::createDefault();  | 
                                                        |
| 115 | + $configObject->loadArray($this->getConfig());  | 
                                                        |
| 116 | + }  | 
                                                        |
| 117 | 117 | |
| 118 | - // Setup the custom definition  | 
                                                        |
| 119 | -		$configObject->set('HTML.DefinitionID', $definitionConfig['id']); | 
                                                        |
| 120 | -		$configObject->set('HTML.DefinitionRev', $definitionConfig['rev']); | 
                                                        |
| 118 | + // Setup the custom definition  | 
                                                        |
| 119 | +        $configObject->set('HTML.DefinitionID', $definitionConfig['id']); | 
                                                        |
| 120 | +        $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']); | 
                                                        |
| 121 | 121 | |
| 122 | - // Enable debug mode  | 
                                                        |
| 123 | -		if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) { | 
                                                        |
| 124 | -			$configObject->set('Cache.DefinitionImpl', null); | 
                                                        |
| 125 | - }  | 
                                                        |
| 122 | + // Enable debug mode  | 
                                                        |
| 123 | +        if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) { | 
                                                        |
| 124 | +            $configObject->set('Cache.DefinitionImpl', null); | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | 126 | |
| 127 | - // Start configuring the definition  | 
                                                        |
| 128 | -		if ($def = $configObject->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 129 | - // Create the definition attributes  | 
                                                        |
| 130 | -			if (!empty($definitionConfig['attributes'])) { | 
                                                        |
| 131 | - $this->addCustomAttributes($definitionConfig['attributes'], $def);  | 
                                                        |
| 132 | - }  | 
                                                        |
| 127 | + // Start configuring the definition  | 
                                                        |
| 128 | +        if ($def = $configObject->maybeGetRawHTMLDefinition()) { | 
                                                        |
| 129 | + // Create the definition attributes  | 
                                                        |
| 130 | +            if (!empty($definitionConfig['attributes'])) { | 
                                                        |
| 131 | + $this->addCustomAttributes($definitionConfig['attributes'], $def);  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | 133 | |
| 134 | - // Create the definition elements  | 
                                                        |
| 135 | -			if (!empty($definitionConfig['elements'])) { | 
                                                        |
| 136 | - $this->addCustomElements($definitionConfig['elements'], $def);  | 
                                                        |
| 137 | - }  | 
                                                        |
| 138 | - }  | 
                                                        |
| 134 | + // Create the definition elements  | 
                                                        |
| 135 | +            if (!empty($definitionConfig['elements'])) { | 
                                                        |
| 136 | + $this->addCustomElements($definitionConfig['elements'], $def);  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | + }  | 
                                                        |
| 139 | 139 | |
| 140 | - return $configObject;  | 
                                                        |
| 141 | - }  | 
                                                        |
| 140 | + return $configObject;  | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | 142 | |
| 143 | - /**  | 
                                                        |
| 144 | - * Add provided attributes to the provided definition  | 
                                                        |
| 145 | - *  | 
                                                        |
| 146 | - * @param array $attributes  | 
                                                        |
| 147 | - * @param HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 148 | - *  | 
                                                        |
| 149 | - * @return HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 150 | - */  | 
                                                        |
| 151 | - private function addCustomAttributes(array $attributes, $definition)  | 
                                                        |
| 152 | -	{ | 
                                                        |
| 153 | -		foreach ($attributes as $attribute) { | 
                                                        |
| 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];  | 
                                                        |
| 143 | + /**  | 
                                                        |
| 144 | + * Add provided attributes to the provided definition  | 
                                                        |
| 145 | + *  | 
                                                        |
| 146 | + * @param array $attributes  | 
                                                        |
| 147 | + * @param HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 148 | + *  | 
                                                        |
| 149 | + * @return HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 150 | + */  | 
                                                        |
| 151 | + private function addCustomAttributes(array $attributes, $definition)  | 
                                                        |
| 152 | +    { | 
                                                        |
| 153 | +        foreach ($attributes as $attribute) { | 
                                                        |
| 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];  | 
                                                        |
| 159 | 159 | |
| 160 | - $definition->addAttribute($onElement, $attrName, $validValues);  | 
                                                        |
| 161 | - }  | 
                                                        |
| 160 | + $definition->addAttribute($onElement, $attrName, $validValues);  | 
                                                        |
| 161 | + }  | 
                                                        |
| 162 | 162 | |
| 163 | - return $definition;  | 
                                                        |
| 164 | - }  | 
                                                        |
| 163 | + return $definition;  | 
                                                        |
| 164 | + }  | 
                                                        |
| 165 | 165 | |
| 166 | - /**  | 
                                                        |
| 167 | - * Add provided elements to the provided definition  | 
                                                        |
| 168 | - *  | 
                                                        |
| 169 | - * @param array $elements  | 
                                                        |
| 170 | - * @param HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 171 | - *  | 
                                                        |
| 172 | - * @return HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 173 | - */  | 
                                                        |
| 174 | - private function addCustomElements(array $elements, $definition)  | 
                                                        |
| 175 | -	{ | 
                                                        |
| 176 | -		foreach ($elements as $element) { | 
                                                        |
| 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;  | 
                                                        |
| 166 | + /**  | 
                                                        |
| 167 | + * Add provided elements to the provided definition  | 
                                                        |
| 168 | + *  | 
                                                        |
| 169 | + * @param array $elements  | 
                                                        |
| 170 | + * @param HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 171 | + *  | 
                                                        |
| 172 | + * @return HTMLPurifier_HTMLDefinition $definition  | 
                                                        |
| 173 | + */  | 
                                                        |
| 174 | + private function addCustomElements(array $elements, $definition)  | 
                                                        |
| 175 | +    { | 
                                                        |
| 176 | +        foreach ($elements as $element) { | 
                                                        |
| 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;  | 
                                                        |
| 183 | 183 | |
| 184 | -			if (!empty($attributes)) { | 
                                                        |
| 185 | - $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes);  | 
                                                        |
| 186 | -			} else { | 
                                                        |
| 187 | - $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection);  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | - }  | 
                                                        |
| 190 | - }  | 
                                                        |
| 184 | +            if (!empty($attributes)) { | 
                                                        |
| 185 | + $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes);  | 
                                                        |
| 186 | +            } else { | 
                                                        |
| 187 | + $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection);  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | + }  | 
                                                        |
| 191 | 191 | |
| 192 | 192 | /**  | 
                                                        
| 193 | 193 | * Check/Create cache directory  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -42,23 +42,23 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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 | |
@@ -49,30 +49,30 @@ discard block  | 
                                                    ||
| 49 | 49 | ['header', 'Block', 'Flow', 'Common'],  | 
                                                        
| 50 | 50 | ['footer', 'Block', 'Flow', 'Common'],  | 
                                                        
| 51 | 51 | |
| 52 | - // Content model actually excludes several tags, not modelled here  | 
                                                        |
| 52 | + // Content model actually excludes several tags, not modelled here  | 
                                                        |
| 53 | 53 | ['address', 'Block', 'Flow', 'Common'],  | 
                                                        
| 54 | 54 | ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],  | 
                                                        
| 55 | 55 | |
| 56 | - // http://developers.whatwg.org/grouping-content.html  | 
                                                        |
| 56 | + // http://developers.whatwg.org/grouping-content.html  | 
                                                        |
| 57 | 57 | ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],  | 
                                                        
| 58 | 58 | ['figcaption', 'Inline', 'Flow', 'Common'],  | 
                                                        
| 59 | 59 | |
| 60 | - // http://developers.whatwg.org/the-video-element.html#the-video-element  | 
                                                        |
| 60 | + // http://developers.whatwg.org/the-video-element.html#the-video-element  | 
                                                        |
| 61 | 61 | ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [  | 
                                                        
| 62 | 62 | 'src' => 'URI',  | 
                                                        
| 63 | - 'type' => 'Text',  | 
                                                        |
| 64 | - 'width' => 'Length',  | 
                                                        |
| 65 | - 'height' => 'Length',  | 
                                                        |
| 66 | - 'poster' => 'URI',  | 
                                                        |
| 67 | - 'preload' => 'Enum#auto,metadata,none',  | 
                                                        |
| 68 | - 'controls' => 'Bool',  | 
                                                        |
| 63 | + 'type' => 'Text',  | 
                                                        |
| 64 | + 'width' => 'Length',  | 
                                                        |
| 65 | + 'height' => 'Length',  | 
                                                        |
| 66 | + 'poster' => 'URI',  | 
                                                        |
| 67 | + 'preload' => 'Enum#auto,metadata,none',  | 
                                                        |
| 68 | + 'controls' => 'Bool',  | 
                                                        |
| 69 | 69 | ]],  | 
                                                        
| 70 | 70 | ['source', 'Block', 'Flow', 'Common', [  | 
                                                        
| 71 | - 'src' => 'URI',  | 
                                                        |
| 72 | - 'type' => 'Text',  | 
                                                        |
| 71 | + 'src' => 'URI',  | 
                                                        |
| 72 | + 'type' => 'Text',  | 
                                                        |
| 73 | 73 | ]],  | 
                                                        
| 74 | 74 | |
| 75 | - // http://developers.whatwg.org/text-level-semantics.html  | 
                                                        |
| 75 | + // http://developers.whatwg.org/text-level-semantics.html  | 
                                                        |
| 76 | 76 | ['s', 'Inline', 'Inline', 'Common'],  | 
                                                        
| 77 | 77 | ['var', 'Inline', 'Inline', 'Common'],  | 
                                                        
| 78 | 78 | ['sub', 'Inline', 'Inline', 'Common'],  | 
                                                        
@@ -80,7 +80,7 @@ discard block  | 
                                                    ||
| 80 | 80 | ['mark', 'Inline', 'Inline', 'Common'],  | 
                                                        
| 81 | 81 | ['wbr', 'Inline', 'Empty', 'Core'],  | 
                                                        
| 82 | 82 | |
| 83 | - // http://developers.whatwg.org/edits.html  | 
                                                        |
| 83 | + // http://developers.whatwg.org/edits.html  | 
                                                        |
| 84 | 84 | ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],  | 
                                                        
| 85 | 85 | ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],  | 
                                                        
| 86 | 86 | ],  | 
                                                        
@@ -1,6 +1,6 @@  | 
                                                    ||
| 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); |