| @@ -99,7 +99,7 @@ | ||
| 99 | 99 | */ | 
| 100 | 100 | public function returnTotal() | 
| 101 | 101 |  	{ | 
| 102 | - $this->_returnTotal=($this->_start == 0); | |
| 102 | + $this->_returnTotal = ($this->_start == 0); | |
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | /** | 
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | */ | 
| 26 | 26 | public static function maxUploadSize() | 
| 27 | 27 |  	{ | 
| 28 | -		$postMax =  Str::toBytes(ini_get('post_max_size')); | |
| 28 | +		$postMax = Str::toBytes(ini_get('post_max_size')); | |
| 29 | 29 |  		$uploadMax = Str::toBytes(ini_get('upload_max_filesize')); | 
| 30 | 30 | return min($postMax, $uploadMax); | 
| 31 | 31 | } | 
| @@ -31,9 +31,9 @@ discard block | ||
| 31 | 31 | * @param bool $scheme - whether to add the http / https scheme | 
| 32 | 32 | * @return string | 
| 33 | 33 | */ | 
| 34 | - public static function baseUrl($url, $scheme=false) | |
| 34 | + public static function baseUrl($url, $scheme = false) | |
| 35 | 35 |  	{ | 
| 36 | - return self::base($scheme) . '/' . ltrim($url, '/'); | |
| 36 | + return self::base($scheme).'/'.ltrim($url, '/'); | |
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | 39 | /** | 
| @@ -42,9 +42,9 @@ discard block | ||
| 42 | 42 | * @param type $scheme | 
| 43 | 43 | * @return type | 
| 44 | 44 | */ | 
| 45 | - public static function getPageUrl($pageId, $scheme=false) | |
| 45 | + public static function getPageUrl($pageId, $scheme = false) | |
| 46 | 46 |  	{ | 
| 47 | -		return self::base($scheme) . neon('cms')->page->getUrlOfPage($pageId); | |
| 47 | +		return self::base($scheme).neon('cms')->page->getUrlOfPage($pageId); | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | /** | 
| @@ -58,18 +58,18 @@ discard block | ||
| 58 | 58 | * @return boolean | 
| 59 | 59 | * @deprected use neon()->request->isRoute(); which copes with unlimited nesting and wilcard patterns as well as param matching | 
| 60 | 60 | */ | 
| 61 | - public static function isRoute($route, $currentUrl=false) | |
| 61 | + public static function isRoute($route, $currentUrl = false) | |
| 62 | 62 |  	{ | 
| 63 | 63 |  		// deprecated('\neon\core\helpers\Url::isRoute', 'Please use neon()->request->isRoute() which copes with unlimited nesting and wilcard patterns as well as param matching'); | 
| 64 | 64 |  		$r = explode('/', trim($route, '/')); | 
| 65 | 65 | $currentUrl ? $currentUrl : \Neon::$app->controller->getRoute(); | 
| 66 | -		$currentRoute = explode('/', trim($currentUrl,'/')); | |
| 66 | +		$currentRoute = explode('/', trim($currentUrl, '/')); | |
| 67 | 67 | |
| 68 | 68 | $m = Arr::getValue($currentRoute, 0); // module | 
| 69 | 69 | $c = Arr::getValue($currentRoute, 1); // controller | 
| 70 | 70 | $a = Arr::getValue($currentRoute, 2); // action | 
| 71 | 71 | |
| 72 | -		switch(count($r)){ | |
| 72 | +		switch (count($r)) { | |
| 73 | 73 | case 1: | 
| 74 | 74 | // match just module | 
| 75 | 75 | return $r[0] == $m; | 
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 | return ($r[0] == $m && $r[1] == $c); | 
| 79 | 79 | case 3: | 
| 80 | 80 | // match the module / controller /action | 
| 81 | - return ($r[0] == $m && $r[1] == $c && $r[2] == $a) ; | |
| 81 | + return ($r[0] == $m && $r[1] == $c && $r[2] == $a); | |
| 82 | 82 | } | 
| 83 | 83 | return false; | 
| 84 | 84 | } | 
| @@ -108,7 +108,7 @@ discard block | ||
| 108 | 108 | // if an array is passed in it will get nested one level because of the spread operator | 
| 109 | 109 | if (is_array($urls[0])) $urls = $urls[0]; | 
| 110 | 110 | $currentUrl = neon()->request->getPathInfo(); | 
| 111 | -		foreach($urls as $url) { | |
| 111 | +		foreach ($urls as $url) { | |
| 112 | 112 | $url = str_replace(Url::base(), '', $url); | 
| 113 | 113 |  			if ($currentUrl !== '' && ltrim($url, '/') === $currentUrl) { | 
| 114 | 114 | return true; | 
| @@ -106,7 +106,9 @@ | ||
| 106 | 106 | public static function isUrl(...$urls) | 
| 107 | 107 |  	{ | 
| 108 | 108 | // if an array is passed in it will get nested one level because of the spread operator | 
| 109 | - if (is_array($urls[0])) $urls = $urls[0]; | |
| 109 | +		if (is_array($urls[0])) { | |
| 110 | + $urls = $urls[0]; | |
| 111 | + } | |
| 110 | 112 | $currentUrl = neon()->request->getPathInfo(); | 
| 111 | 113 |  		foreach($urls as $url) { | 
| 112 | 114 | $url = str_replace(Url::base(), '', $url); | 
| @@ -175,9 +175,9 @@ | ||
| 175 | 175 | ]); | 
| 176 | 176 | } | 
| 177 | 177 |   		if ($userItems) { | 
| 178 | - $out .= \yii\widgets\Menu::widget([ | |
| 179 | - // this is the old code to use the yii/bootstrap extension | |
| 180 | - // it becomes very hard to remove bootstrap if we use these. | |
| 178 | + $out .= \yii\widgets\Menu::widget([ | |
| 179 | + // this is the old code to use the yii/bootstrap extension | |
| 180 | + // it becomes very hard to remove bootstrap if we use these. | |
| 181 | 181 | 'options'=> ['class' => 'navbar-nav navbar-right nav'], | 
| 182 | 182 | 'items'=> $userItems['items'] | 
| 183 | 183 | ]); | 
| @@ -59,7 +59,7 @@ discard block | ||
| 59 | 59 | 'load' => View::POS_LOAD, | 
| 60 | 60 | ]; | 
| 61 | 61 |  		if (!array_key_exists($position, $positions)) { | 
| 62 | -			throw new \Exception('The javascript position specified must be one of ' . print_r(array_keys($positions)) . ', you specified "'.$position.'"'); | |
| 62 | +			throw new \Exception('The javascript position specified must be one of '.print_r(array_keys($positions)).', you specified "'.$position.'"'); | |
| 63 | 63 | } | 
| 64 | 64 | Js::begin(['position' => $positions[$position]]); | 
| 65 | 65 | } | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | * @param string $image - url | 
| 117 | 117 | * @return string | 
| 118 | 118 | */ | 
| 119 | - public static function userMenuCard($name=null, $email=null, $image=null) | |
| 119 | + public static function userMenuCard($name = null, $email = null, $image = null) | |
| 120 | 120 |  	{ | 
| 121 | 121 |  		if ($name == null && $email == null && $image == null) { | 
| 122 | 122 | $u = neon()->user; | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 |  		static::getMenuManager()->add('user', [ | 
| 142 | 142 |  			'template' => '<a href="{url}" class="dropdown-toggle navbarUserDropdown" data-toggle="dropdown">{label}</a>', | 
| 143 | 143 | 'options' => ['class'=>'dropdown navbarUserDropdown'], | 
| 144 | - 'label' => neon()->user->isGuest ? 'Guest' : '<img class="nav-avatar avatar" src="' . neon()->user->getImageUrl(30) . '"/> ' . neon()->user->getName(), | |
| 144 | + 'label' => neon()->user->isGuest ? 'Guest' : '<img class="nav-avatar avatar" src="'.neon()->user->getImageUrl(30).'"/> '.neon()->user->getName(), | |
| 145 | 145 | 'url' => ['/user/account/index'], | 
| 146 | 146 | 'linkOptions' => ['class' => 'navbarUserDropdown'], | 
| 147 | 147 | 'encode' => false, | 
| @@ -153,12 +153,12 @@ discard block | ||
| 153 | 153 | |
| 154 | 154 | //['label' => '<i class="fa fa-cog" aria-hidden="true"></i> My Account', 'url' => ['/user/account/index'], 'encode'=>false ], | 
| 155 | 155 | //'<li class="divider"></li>', | 
| 156 | - ['label' => '<i class="fa fa-sign-out" aria-hidden="true"></i> Log Out', 'url' => ['/user/account/logout'], 'encode'=>false ] | |
| 156 | + ['label' => '<i class="fa fa-sign-out" aria-hidden="true"></i> Log Out', 'url' => ['/user/account/logout'], 'encode'=>false] | |
| 157 | 157 | ] | 
| 158 | 158 | ]); | 
| 159 | 159 | $adminItems = static::getMenuManager()->getMainAdminMenu(); | 
| 160 | -		foreach($adminItems as $key => $items) { | |
| 161 | -			foreach($items as $key2 => $item) { | |
| 160 | +		foreach ($adminItems as $key => $items) { | |
| 161 | +			foreach ($items as $key2 => $item) { | |
| 162 | 162 |  				if (isset($item['visible'])) { | 
| 163 | 163 | $adminItems[$key][$key2]['visible'] = value($item['visible']); | 
| 164 | 164 | } | 
| @@ -13,10 +13,10 @@ discard block | ||
| 13 | 13 | * @param array $tagsArray | 
| 14 | 14 | * @param string $class - css classes to apply to the wrapping tag | 
| 15 | 15 | */ | 
| 16 | - public static function displayAsTags($tagsArray, $class='label label-info') | |
| 16 | + public static function displayAsTags($tagsArray, $class = 'label label-info') | |
| 17 | 17 |  	{ | 
| 18 | 18 | $out = ''; | 
| 19 | -		foreach($tagsArray as $tag) { | |
| 19 | +		foreach ($tagsArray as $tag) { | |
| 20 | 20 | $out .= "<span class=\"$class\">$tag</span>"; | 
| 21 | 21 | } | 
| 22 | 22 | return $out; | 
| @@ -33,9 +33,9 @@ discard block | ||
| 33 | 33 | * - specify $options['icon'] | 
| 34 | 34 | * @return string Html for the custom button | 
| 35 | 35 | */ | 
| 36 | - public static function buttonCustom($url, $text, array $options=[]) | |
| 36 | + public static function buttonCustom($url, $text, array $options = []) | |
| 37 | 37 |  	{ | 
| 38 | - $options['class'] = 'btn '. Arr::get($options, 'class', ''); | |
| 38 | + $options['class'] = 'btn '.Arr::get($options, 'class', ''); | |
| 39 | 39 | $icon = Arr::remove($options, 'icon', ''); | 
| 40 | 40 |  		return self::a("<i class=\"$icon\"></i> ".$text, $url, $options); | 
| 41 | 41 | } | 
| @@ -47,10 +47,10 @@ discard block | ||
| 47 | 47 | * @param string $text - button text | 
| 48 | 48 | * @return string Html for an edit button | 
| 49 | 49 | */ | 
| 50 | - public static function buttonEdit($url, $text='Edit', $options=[]) | |
| 50 | + public static function buttonEdit($url, $text = 'Edit', $options = []) | |
| 51 | 51 |  	{ | 
| 52 | 52 | $options['icon'] = 'fa fa-pencil'; | 
| 53 | - $options['class'] = 'btn-default ' . Arr::get($options, 'class', ''); | |
| 53 | + $options['class'] = 'btn-default '.Arr::get($options, 'class', ''); | |
| 54 | 54 | return self::buttonCustom($url, $text, $options); | 
| 55 | 55 | } | 
| 56 | 56 | |
| @@ -62,10 +62,10 @@ discard block | ||
| 62 | 62 | * @see \yii\helpers\Url::to | 
| 63 | 63 | * @return string Html | 
| 64 | 64 | */ | 
| 65 | - public static function buttonDelete($url, $text='Delete', $options=[]) | |
| 65 | + public static function buttonDelete($url, $text = 'Delete', $options = []) | |
| 66 | 66 |  	{ | 
| 67 | 67 | $options['icon'] = 'fa fa-trash'; | 
| 68 | - $options['class'] = 'btn-danger ' . Arr::get($options, 'class', ''); | |
| 68 | + $options['class'] = 'btn-danger '.Arr::get($options, 'class', ''); | |
| 69 | 69 | return self::buttonCustom($url, $text, $options); | 
| 70 | 70 | } | 
| 71 | 71 | |
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | * @see \yii\helpers\Url::to | 
| 78 | 78 | * @return string Html | 
| 79 | 79 | */ | 
| 80 | - public static function buttonAdd($url, $text='Add', $options=[]) | |
| 80 | + public static function buttonAdd($url, $text = 'Add', $options = []) | |
| 81 | 81 |  	{ | 
| 82 | 82 | $options['icon'] = 'fa fa-plus'; | 
| 83 | 83 | $options['class'] = 'btn-primary btn-add'; | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | * @param string $text button text | 
| 92 | 92 | * @return string Html | 
| 93 | 93 | */ | 
| 94 | - public static function buttonCancel($url='', $text='Cancel', $options=[]) | |
| 94 | + public static function buttonCancel($url = '', $text = 'Cancel', $options = []) | |
| 95 | 95 |  	{ | 
| 96 | 96 | $options['icon'] = 'fa fa-arrow-left'; | 
| 97 | 97 | $options['class'] = 'btn-default btn-cancel'; | 
| @@ -127,7 +127,7 @@ discard block | ||
| 127 | 127 | public static function checkbox($name, $checked = false, $options = []) | 
| 128 | 128 |  	{ | 
| 129 | 129 | $checkbox = parent::checkbox($name, $checked, $options); | 
| 130 | - return '<div class="checkbox">' . $checkbox . '</div>'; | |
| 130 | + return '<div class="checkbox">'.$checkbox.'</div>'; | |
| 131 | 131 | } | 
| 132 | 132 | |
| 133 | 133 | /** | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | public static function radio($name, $checked = false, $options = []) | 
| 137 | 137 |  	{ | 
| 138 | 138 | $radio = parent::radio($name, $checked, $options); | 
| 139 | - return '<div class="radio">' . $radio . '</div>'; | |
| 139 | + return '<div class="radio">'.$radio.'</div>'; | |
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | 142 | /** | 
| @@ -230,13 +230,13 @@ discard block | ||
| 230 | 230 | protected static function processTags($openingTags, &$tagsProcessed) | 
| 231 | 231 |  	{ | 
| 232 | 232 | // append the closing tags to the list and add a comma for splitting later | 
| 233 | -		$tagsStr = str_replace('>','>,',($openingTags.str_replace('<','</',$openingTags))); | |
| 233 | +		$tagsStr = str_replace('>', '>,', ($openingTags.str_replace('<', '</', $openingTags))); | |
| 234 | 234 | // create the replacement code with a highly unlikely set of strings | 
| 235 | 235 | $replaceStr = str_replace(['</', '<', '/>', '>'], ['__NEWICON_CLOSELT__', '__NEWICON_LT__', '__NEWICON_CLOSERT__', '__NEWICON_RT__'], $tagsStr); | 
| 236 | 236 | |
| 237 | 237 | // now create the replacement and returned tags | 
| 238 | -		$replaceTags = explode(',', substr($replaceStr,0,-1)); // ignore trailing comma | |
| 239 | -		$returnTags = explode(',', substr($tagsStr,0,-1)); // ignore trailing comma | |
| 238 | +		$replaceTags = explode(',', substr($replaceStr, 0, -1)); // ignore trailing comma | |
| 239 | +		$returnTags = explode(',', substr($tagsStr, 0, -1)); // ignore trailing comma | |
| 240 | 240 | $tagsProcessed[$openingTags] = ['replace'=>$replaceTags, 'return'=>$returnTags]; | 
| 241 | 241 | } | 
| 242 | 242 | |
| @@ -249,7 +249,7 @@ discard block | ||
| 249 | 249 | * @param string $empty - what to show if the field is empty | 
| 250 | 250 | * @return string html | 
| 251 | 251 | */ | 
| 252 | - public static function highlight($search, $html, $empty='') | |
| 252 | + public static function highlight($search, $html, $empty = '') | |
| 253 | 253 |  	{ | 
| 254 | 254 | if ($html === null) | 
| 255 | 255 | return neon()->formatter->nullDisplay; | 
| @@ -268,7 +268,7 @@ discard block | ||
| 268 | 268 | // loadHtml seems to ignore the LIBXML_ERR_NONE setting | 
| 269 | 269 | // we don;t care if we are not given perfectly formed html | 
| 270 | 270 | // Even if we have serious issues in the html `$dom->saveHtml` makes a good expected effort | 
| 271 | -				@$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html, LIBXML_HTML_NOIMPLIED + LIBXML_HTML_NODEFDTD + LIBXML_NONET + LIBXML_ERR_NONE); | |
| 271 | +				@$dom->loadHTML('<?xml encoding="utf-8" ?>'.$html, LIBXML_HTML_NOIMPLIED + LIBXML_HTML_NODEFDTD + LIBXML_NONET + LIBXML_ERR_NONE); | |
| 272 | 272 | $xpath = new \DOMXPath($dom); | 
| 273 | 273 | $s = htmlentities($s); | 
| 274 | 274 | $findStack = []; | 
| @@ -278,8 +278,8 @@ discard block | ||
| 278 | 278 | // appendXml is useless and will break easily when exposed to characters | 
| 279 | 279 | // preg_replace is a million times more robust.... | 
| 280 | 280 | // So keep the dom parser happy by replacing its internal text with an md5 key | 
| 281 | -					$replace = preg_replace('/(' . preg_quote($s) . ')/i', '<span class="neonSearchHighlight">$1</span>', htmlentities($node->nodeValue)); | |
| 282 | -					$key = '{[' . md5($replace) . ']}'; | |
| 281 | +					$replace = preg_replace('/('.preg_quote($s).')/i', '<span class="neonSearchHighlight">$1</span>', htmlentities($node->nodeValue)); | |
| 282 | +					$key = '{['.md5($replace).']}'; | |
| 283 | 283 | $findStack[$key] = $replace; | 
| 284 | 284 | $f->appendXML($key); | 
| 285 | 285 | $node->parentNode->replaceChild($f, $node); | 
| @@ -154,8 +154,9 @@ discard block | ||
| 154 | 154 | self::processTags($allowableTags, $tagsProcessed); | 
| 155 | 155 | } | 
| 156 | 156 |  		if (is_array($value)) { | 
| 157 | - foreach ($value as $k => $v) | |
| 158 | - $value[$k] = static::sanitise($v, $allowableTags); | |
| 157 | +			foreach ($value as $k => $v) { | |
| 158 | + $value[$k] = static::sanitise($v, $allowableTags); | |
| 159 | + } | |
| 159 | 160 |  		} else { | 
| 160 | 161 |  			if (!is_null($value)) { | 
| 161 | 162 |  				if (isset($tagsProcessed[$allowableTags])) { | 
| @@ -189,14 +190,16 @@ discard block | ||
| 189 | 190 |  	{ | 
| 190 | 191 |  		profile_begin('Html::purify', 'html'); | 
| 191 | 192 |  		if (is_array($value)) { | 
| 192 | - foreach ($value as $k => $v) | |
| 193 | - $value[$k] = static::purify($v, $allowedTags); | |
| 193 | +			foreach ($value as $k => $v) { | |
| 194 | + $value[$k] = static::purify($v, $allowedTags); | |
| 195 | + } | |
| 194 | 196 |  		} else { | 
| 195 | 197 |  			if (!is_null($value)) { | 
| 196 | - if ($allowedTags === false) | |
| 197 | - $value = trim(HtmlPurifier::process($value)); | |
| 198 | - else | |
| 199 | - $value = trim(HtmlPurifier::process(strip_tags($value, $allowedTags))); | |
| 198 | +				if ($allowedTags === false) { | |
| 199 | + $value = trim(HtmlPurifier::process($value)); | |
| 200 | +				} else { | |
| 201 | + $value = trim(HtmlPurifier::process(strip_tags($value, $allowedTags))); | |
| 202 | + } | |
| 200 | 203 | } | 
| 201 | 204 | } | 
| 202 | 205 |  		profile_end('Html::purify', 'html'); | 
| @@ -214,8 +217,9 @@ discard block | ||
| 214 | 217 | public static function encodeEntities($value, $entities = ENT_QUOTES) | 
| 215 | 218 |  	{ | 
| 216 | 219 |  		if (is_array($value)) { | 
| 217 | - foreach ($value as $k => $v) | |
| 218 | - $value[$k] = static::encodeEntities($v, $entities); | |
| 220 | +			foreach ($value as $k => $v) { | |
| 221 | + $value[$k] = static::encodeEntities($v, $entities); | |
| 222 | + } | |
| 219 | 223 |  		} else { | 
| 220 | 224 | $value = htmlentities($value, $entities); | 
| 221 | 225 | } | 
| @@ -251,18 +255,22 @@ discard block | ||
| 251 | 255 | */ | 
| 252 | 256 | public static function highlight($search, $html, $empty='') | 
| 253 | 257 |  	{ | 
| 254 | - if ($html === null) | |
| 255 | - return neon()->formatter->nullDisplay; | |
| 256 | - if ($html === '') | |
| 257 | - return $empty; | |
| 258 | - if (empty($search)) | |
| 259 | - return $html; | |
| 258 | +		if ($html === null) { | |
| 259 | + return neon()->formatter->nullDisplay; | |
| 260 | + } | |
| 261 | +		if ($html === '') { | |
| 262 | + return $empty; | |
| 263 | + } | |
| 264 | +		if (empty($search)) { | |
| 265 | + return $html; | |
| 266 | + } | |
| 260 | 267 | |
| 261 | 268 |  		profile_begin('Html::Highlight'); | 
| 262 | 269 | // escape search and html entities as otherwise the loadHTML or appendXML | 
| 263 | 270 | // can blow up if there are < & > in the data | 
| 264 | - if (!is_array($search)) | |
| 265 | - $search = [$search]; | |
| 271 | +		if (!is_array($search)) { | |
| 272 | + $search = [$search]; | |
| 273 | + } | |
| 266 | 274 |  		try { | 
| 267 | 275 |  			foreach ($search as $s) { | 
| 268 | 276 | // now search and rebuild the data | 
| @@ -38,9 +38,9 @@ discard block | ||
| 38 | 38 | |
| 39 | 39 |  		foreach ($array as $key => $value) { | 
| 40 | 40 |  			if (is_array($value) && !empty($value)) { | 
| 41 | - $results = array_merge($results, static::dot($value, $prepend . $key . '.')); | |
| 41 | + $results = array_merge($results, static::dot($value, $prepend.$key.'.')); | |
| 42 | 42 |  			} else { | 
| 43 | - $results[$prepend . $key] = $value; | |
| 43 | + $results[$prepend.$key] = $value; | |
| 44 | 44 | } | 
| 45 | 45 | } | 
| 46 | 46 | |
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | */ | 
| 142 | 142 | public static function flatten($array, $depth = INF) | 
| 143 | 143 |  	{ | 
| 144 | -		return array_reduce($array, function ($result, $item) use ($depth) { | |
| 144 | +		return array_reduce($array, function($result, $item) use ($depth) { | |
| 145 | 145 | $item = $item instanceof Collection ? $item->all() : $item; | 
| 146 | 146 | |
| 147 | 147 |  			if (!is_array($item)) { | 
| @@ -165,7 +165,7 @@ discard block | ||
| 165 | 165 |  	{ | 
| 166 | 166 | $original = &$array; | 
| 167 | 167 | |
| 168 | - $keys = (array)$keys; | |
| 168 | + $keys = (array) $keys; | |
| 169 | 169 | |
| 170 | 170 |  		if (count($keys) === 0) { | 
| 171 | 171 | return; | 
| @@ -400,7 +400,7 @@ discard block | ||
| 400 | 400 | */ | 
| 401 | 401 | public static function only($array, $keys) | 
| 402 | 402 |  	{ | 
| 403 | - return array_intersect_key($array, array_flip((array)$keys)); | |
| 403 | + return array_intersect_key($array, array_flip((array) $keys)); | |
| 404 | 404 | } | 
| 405 | 405 | |
| 406 | 406 | /** | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | * @param string $type - one of 'date' | 'datetime' | 'time' | 
| 28 | 28 | * @return null|string date in format defined by $toFormat | 
| 29 | 29 | */ | 
| 30 | - public static function convertDate($date, $fromFormat, $toFormat, $type='date') | |
| 30 | + public static function convertDate($date, $fromFormat, $toFormat, $type = 'date') | |
| 31 | 31 |  	{ | 
| 32 | 32 | $date = \DateTime::createFromFormat(self::convertDateFormatToPhp($fromFormat), $date); | 
| 33 | 33 | return is_bool($date) ? null : $date->format(self::convertDateFormatToPhp($toFormat, $type)); | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | * @param string $type - one of 'date' | 'datetime' | 'time' | 
| 64 | 64 | * @return string - string representing a php date format | 
| 65 | 65 | */ | 
| 66 | - public static function convertDateFormatToPhp($format, $type='date') | |
| 66 | + public static function convertDateFormatToPhp($format, $type = 'date') | |
| 67 | 67 |  	{ | 
| 68 | 68 | if (strncmp($format, 'php:', 4) === 0) | 
| 69 | 69 | return substr($format, 4); | 
| @@ -47,10 +47,12 @@ discard block | ||
| 47 | 47 | */ | 
| 48 | 48 | public static function convertDateFormatToJui($format) | 
| 49 | 49 |  	{ | 
| 50 | - if (strncmp($format, 'php:', 4) === 0) | |
| 51 | - return self::convertDatePhpToJui(substr($format, 4)); | |
| 52 | - if (strncmp($format, 'icu:', 4) === 0) | |
| 53 | - return self::convertDateIcuToJui(substr($format, 4)); | |
| 50 | +		if (strncmp($format, 'php:', 4) === 0) { | |
| 51 | + return self::convertDatePhpToJui(substr($format, 4)); | |
| 52 | + } | |
| 53 | +		if (strncmp($format, 'icu:', 4) === 0) { | |
| 54 | + return self::convertDateIcuToJui(substr($format, 4)); | |
| 55 | + } | |
| 54 | 56 | return self::convertDateIcuToJui($format); | 
| 55 | 57 | } | 
| 56 | 58 | |
| @@ -65,10 +67,12 @@ discard block | ||
| 65 | 67 | */ | 
| 66 | 68 | public static function convertDateFormatToPhp($format, $type='date') | 
| 67 | 69 |  	{ | 
| 68 | - if (strncmp($format, 'php:', 4) === 0) | |
| 69 | - return substr($format, 4); | |
| 70 | - if (strncmp($format, 'icu:', 4) === 0) | |
| 71 | - return self::convertDateIcuToPhp(substr($format, 4), $type); | |
| 70 | +		if (strncmp($format, 'php:', 4) === 0) { | |
| 71 | + return substr($format, 4); | |
| 72 | + } | |
| 73 | +		if (strncmp($format, 'icu:', 4) === 0) { | |
| 74 | + return self::convertDateIcuToPhp(substr($format, 4), $type); | |
| 75 | + } | |
| 72 | 76 | // assume icu format by default - this is the default used by neon()->formatter->dateFormat | 
| 73 | 77 | return self::convertDateIcuToPhp($format, $type); | 
| 74 | 78 | } | 
| @@ -202,7 +202,7 @@ discard block | ||
| 202 | 202 | return static::$snakeCache[$key][$delimiter]; | 
| 203 | 203 | } | 
| 204 | 204 | |
| 205 | -		if (! ctype_lower($value)) { | |
| 205 | +		if (!ctype_lower($value)) { | |
| 206 | 206 |  			$value = preg_replace('/\s+/u', '', $value); | 
| 207 | 207 | |
| 208 | 208 |  			$value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value)); | 
| @@ -343,8 +343,7 @@ discard block | ||
| 343 | 343 | public static function replaceFirst($search, $replace, $subject) | 
| 344 | 344 |  	{ | 
| 345 | 345 | $position = strpos($subject, $search); | 
| 346 | - return $position === false ? $subject : | |
| 347 | - substr_replace($subject, $replace, $position, strlen($search)); | |
| 346 | + return $position === false ? $subject : substr_replace($subject, $replace, $position, strlen($search)); | |
| 348 | 347 | } | 
| 349 | 348 | |
| 350 | 349 | /** | 
| @@ -376,8 +375,7 @@ discard block | ||
| 376 | 375 | public static function iReplaceFirst($search, $replace, $subject) | 
| 377 | 376 |  	{ | 
| 378 | 377 | $position = stripos($subject, $search); | 
| 379 | - return $position === false ? $subject : | |
| 380 | - substr_replace($subject, $replace, $position, strlen($search)); | |
| 378 | + return $position === false ? $subject : substr_replace($subject, $replace, $position, strlen($search)); | |
| 381 | 379 | } | 
| 382 | 380 | |
| 383 | 381 | /** | 
| @@ -392,7 +390,7 @@ discard block | ||
| 392 | 390 |  	{ | 
| 393 | 391 |  		preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); | 
| 394 | 392 | |
| 395 | -		if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { | |
| 393 | +		if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { | |
| 396 | 394 | return $value; | 
| 397 | 395 | } | 
| 398 | 396 | |
| @@ -418,9 +416,9 @@ discard block | ||
| 418 | 416 | */ | 
| 419 | 417 | public static function toBytes($string) | 
| 420 | 418 |  	{ | 
| 421 | - sscanf ($string, '%u%c', $number, $suffix); | |
| 419 | + sscanf($string, '%u%c', $number, $suffix); | |
| 422 | 420 |  		if (isset ($suffix)) { | 
| 423 | -			$number = $number * pow (1024, strpos (' KMGTP', strtoupper($suffix))); | |
| 421 | +			$number = $number * pow(1024, strpos(' KMGTP', strtoupper($suffix))); | |
| 424 | 422 | } | 
| 425 | 423 | return $number; | 
| 426 | 424 | } | 
| @@ -437,7 +435,7 @@ discard block | ||
| 437 | 435 | $base = log($size, 1024); | 
| 438 | 436 |  		$suffixes = array('', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); | 
| 439 | 437 | |
| 440 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; | |
| 438 | + return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; | |
| 441 | 439 | } | 
| 442 | 440 | |
| 443 | 441 | /** | 
| @@ -538,14 +536,14 @@ discard block | ||
| 538 | 536 | * @param array|string $allowedUnits | 
| 539 | 537 | * @return bool | 
| 540 | 538 | */ | 
| 541 | - public static function validateNumericWithUnits($value, $allowedUnits=[]) | |
| 539 | + public static function validateNumericWithUnits($value, $allowedUnits = []) | |
| 542 | 540 |  	{ | 
| 543 | 541 | if (!$allowedUnits) return is_numeric($value); | 
| 544 | - if (is_string($allowedUnits)) $allowedUnits=[$allowedUnits]; | |
| 542 | + if (is_string($allowedUnits)) $allowedUnits = [$allowedUnits]; | |
| 545 | 543 |  		foreach ($allowedUnits as $unit) { | 
| 546 | - $checkNumber = substr($value,0, -strlen($unit)); | |
| 544 | + $checkNumber = substr($value, 0, -strlen($unit)); | |
| 547 | 545 | $checkUnit = substr($value, -strlen($unit)); | 
| 548 | -			if ($checkUnit==$unit && is_numeric($checkNumber)) { | |
| 546 | +			if ($checkUnit == $unit && is_numeric($checkNumber)) { | |
| 549 | 547 | return true; | 
| 550 | 548 | } | 
| 551 | 549 | } | 
| @@ -540,8 +540,12 @@ | ||
| 540 | 540 | */ | 
| 541 | 541 | public static function validateNumericWithUnits($value, $allowedUnits=[]) | 
| 542 | 542 |  	{ | 
| 543 | - if (!$allowedUnits) return is_numeric($value); | |
| 544 | - if (is_string($allowedUnits)) $allowedUnits=[$allowedUnits]; | |
| 543 | +		if (!$allowedUnits) { | |
| 544 | + return is_numeric($value); | |
| 545 | + } | |
| 546 | +		if (is_string($allowedUnits)) { | |
| 547 | + $allowedUnits=[$allowedUnits]; | |
| 548 | + } | |
| 545 | 549 |  		foreach ($allowedUnits as $unit) { | 
| 546 | 550 | $checkNumber = substr($value,0, -strlen($unit)); | 
| 547 | 551 | $checkUnit = substr($value, -strlen($unit)); | 
| @@ -44,12 +44,12 @@ | ||
| 44 | 44 | */ | 
| 45 | 45 | public static function replaceRelativeUrls($cssContent, $publishedCssFilePath) | 
| 46 | 46 |  	{ | 
| 47 | -		$content = preg_replace_callback('/url\(([^)]*)\)/', function ($matches) use ($publishedCssFilePath) { | |
| 47 | +		$content = preg_replace_callback('/url\(([^)]*)\)/', function($matches) use ($publishedCssFilePath) { | |
| 48 | 48 | $url = trim($matches[1], '\'"'); | 
| 49 | 49 | // ignore non url (urls e.g. data:image url paths) and absolute urls | 
| 50 | 50 | if (Url::isAbsolute($url)) | 
| 51 | 51 | return $matches[0]; | 
| 52 | -			return 'url("' . dirname($publishedCssFilePath) . '/' . $url . '")'; | |
| 52 | +			return 'url("'.dirname($publishedCssFilePath).'/'.$url.'")'; | |
| 53 | 53 | }, $cssContent); | 
| 54 | 54 | return $content; | 
| 55 | 55 | } | 
| @@ -47,8 +47,9 @@ | ||
| 47 | 47 |  		$content = preg_replace_callback('/url\(([^)]*)\)/', function ($matches) use ($publishedCssFilePath) { | 
| 48 | 48 | $url = trim($matches[1], '\'"'); | 
| 49 | 49 | // ignore non url (urls e.g. data:image url paths) and absolute urls | 
| 50 | - if (Url::isAbsolute($url)) | |
| 51 | - return $matches[0]; | |
| 50 | +			if (Url::isAbsolute($url)) { | |
| 51 | + return $matches[0]; | |
| 52 | + } | |
| 52 | 53 |  			return 'url("' . dirname($publishedCssFilePath) . '/' . $url . '")'; | 
| 53 | 54 | }, $cssContent); | 
| 54 | 55 | return $content; |