@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Store back |
| 127 | - $data[$key] = $parts; |
|
| 127 | + $data[ $key ] = $parts; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $data; |
@@ -160,16 +160,16 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public static function buildFontsMarkupScript(Collection $collection) |
| 162 | 162 | { |
| 163 | - $families_array = []; |
|
| 163 | + $families_array = [ ]; |
|
| 164 | 164 | |
| 165 | 165 | list($names, $mapping) = $collection->getScriptData(); |
| 166 | 166 | |
| 167 | 167 | foreach ($names as $name => $sizes) { |
| 168 | 168 | $family = $name . ':' . implode(',', $sizes); |
| 169 | - if (isset($mapping[$name])) { |
|
| 170 | - $family .= ':' . implode(',', $mapping[$name]); |
|
| 169 | + if (isset($mapping[ $name ])) { |
|
| 170 | + $family .= ':' . implode(',', $mapping[ $name ]); |
|
| 171 | 171 | } |
| 172 | - $families_array[] = $family; |
|
| 172 | + $families_array[ ] = $family; |
|
| 173 | 173 | } |
| 174 | 174 | $families = "'" . implode("', '", $families_array) . "'"; |
| 175 | 175 | |
@@ -233,28 +233,28 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return null|string |
| 235 | 235 | */ |
| 236 | - public static function buildGoogleFontsUrl(array $fonts, $subsets = []) |
|
| 236 | + public static function buildGoogleFontsUrl(array $fonts, $subsets = [ ]) |
|
| 237 | 237 | { |
| 238 | 238 | $base_url = 'https://fonts.googleapis.com/css'; |
| 239 | - $font_args = []; |
|
| 240 | - $family = []; |
|
| 239 | + $font_args = [ ]; |
|
| 240 | + $family = [ ]; |
|
| 241 | 241 | |
| 242 | 242 | foreach ($fonts as $font_name => $font_weight) { |
| 243 | 243 | if (is_array($font_weight)) { |
| 244 | 244 | $font_weight = implode(',', $font_weight); |
| 245 | 245 | } |
| 246 | 246 | // Trimming end colon handles edge case of being given an empty $font_weight |
| 247 | - $family[] = trim(trim($font_name) . ':' . trim($font_weight), ':'); |
|
| 247 | + $family[ ] = trim(trim($font_name) . ':' . trim($font_weight), ':'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $font_args['family'] = implode('|', $family); |
|
| 250 | + $font_args[ 'family' ] = implode('|', $family); |
|
| 251 | 251 | |
| 252 | - if (! empty($subsets)) { |
|
| 252 | + if (!empty($subsets)) { |
|
| 253 | 253 | if (is_array($subsets)) { |
| 254 | 254 | $subsets = array_unique($subsets); |
| 255 | 255 | $subsets = implode(',', $subsets); |
| 256 | 256 | } |
| 257 | - $font_args['subset'] = trim($subsets); |
|
| 257 | + $font_args[ 'subset' ] = trim($subsets); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $url = $base_url . '?' . http_build_query($font_args); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public static function arrayFlattenIterative(array $arr) |
| 273 | 273 | { |
| 274 | - $flat = []; |
|
| 274 | + $flat = [ ]; |
|
| 275 | 275 | $stack = array_values($arr); |
| 276 | 276 | |
| 277 | 277 | while ($stack) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | if (is_array($value)) { |
| 280 | 280 | $stack = array_merge(array_values($value), $stack); |
| 281 | 281 | } else { |
| 282 | - $flat[] = $value; |
|
| 282 | + $flat[ ] = $value; |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | const FILTER_OB_CLEANER = 'zwf_gfo_clean_ob'; |
| 17 | 17 | const DEFAULT_OB_CLEANER = false; |
| 18 | 18 | |
| 19 | - protected $candidates = []; |
|
| 19 | + protected $candidates = [ ]; |
|
| 20 | 20 | |
| 21 | - protected $enqueued = []; |
|
| 21 | + protected $enqueued = [ ]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param array $urls |
| 25 | 25 | */ |
| 26 | - public function setCandidates(array $urls = []) |
|
| 26 | + public function setCandidates(array $urls = [ ]) |
|
| 27 | 27 | { |
| 28 | 28 | $this->candidates = $urls; |
| 29 | 29 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Scan and optimize requests found in the markup (uses more |
| 53 | 53 | * memory but works on [almost] any theme) |
| 54 | 54 | */ |
| 55 | - add_action('template_redirect', [$this, 'startBuffering'], 11); |
|
| 55 | + add_action('template_redirect', [ $this, 'startBuffering' ], 11); |
|
| 56 | 56 | break; |
| 57 | 57 | |
| 58 | 58 | case self::DEFAULT_OPERATION_MODE: |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * Scan only things added via wp_enqueue_style (uses slightly |
| 62 | 62 | * less memory usually, but requires a decently coded theme) |
| 63 | 63 | */ |
| 64 | - add_filter('print_styles_array', [$this, 'processStylesHandles']); |
|
| 64 | + add_filter('print_styles_array', [ $this, 'processStylesHandles' ]); |
|
| 65 | 65 | break; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $candidate_handles = $this->findCandidateHandles($handles); |
| 84 | 84 | |
| 85 | 85 | // Bail if we don't have anything that makes sense for us to continue |
| 86 | - if (! $this->hasEnoughElements($candidate_handles)) { |
|
| 86 | + if (!$this->hasEnoughElements($candidate_handles)) { |
|
| 87 | 87 | return $handles; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | $font_url = $collection->getCombinedUrl(); |
| 98 | 98 | $handle_name = 'zwf-gfo-combined'; |
| 99 | 99 | $this->enqueueStyle($handle_name, $font_url); |
| 100 | - $handles[] = $handle_name; |
|
| 100 | + $handles[ ] = $handle_name; |
|
| 101 | 101 | |
| 102 | 102 | // Process 'text-only' requests if there are any... |
| 103 | 103 | $texts = $collection->getTextUrls(); |
| 104 | 104 | foreach ($texts as $k => $url) { |
| 105 | 105 | $handle_name = 'zwf-gfo-combined-txt-' . ($k + 1); |
| 106 | 106 | $this->enqueueStyle($handle_name, $url); |
| 107 | - $handles[] = $handle_name; |
|
| 107 | + $handles[ ] = $handle_name; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Remove/dequeue the ones we just combined above |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | public function findCandidateHandles(array $handles) |
| 132 | 132 | { |
| 133 | 133 | $handler = /** @scrutinizer ignore-call */ \wp_styles(); |
| 134 | - $candidate_handles = []; |
|
| 134 | + $candidate_handles = [ ]; |
|
| 135 | 135 | |
| 136 | 136 | foreach ($handles as $handle) { |
| 137 | 137 | $dep = $handler->query($handle, 'registered'); |
| 138 | 138 | if ($dep) { |
| 139 | 139 | $url = $dep->src; |
| 140 | 140 | if (Utils::isGoogleWebFontUrl($url)) { |
| 141 | - $candidate_handles[$handle] = $url; |
|
| 141 | + $candidate_handles[ $handle ] = $url; |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @return bool |
| 155 | 155 | */ |
| 156 | - protected function hasEnoughElements(array $candidates = []) |
|
| 156 | + protected function hasEnoughElements(array $candidates = [ ]) |
|
| 157 | 157 | { |
| 158 | 158 | $enough = true; |
| 159 | 159 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | \wp_dequeue_style($handle); |
| 185 | 185 | } |
| 186 | 186 | // @codeCoverageIgnoreEnd |
| 187 | - unset($this->enqueued[$handle]); |
|
| 187 | + unset($this->enqueued[ $handle ]); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - public function enqueueStyle($handle, $url, $deps = [], $version = null) |
|
| 202 | + public function enqueueStyle($handle, $url, $deps = [ ], $version = null) |
|
| 203 | 203 | { |
| 204 | 204 | // @codeCoverageIgnoreStart |
| 205 | 205 | if (function_exists('\wp_enqueue_style')) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | // @codeCoverageIgnoreEnd |
| 210 | 210 | |
| 211 | - $this->enqueued[$handle] = $url; |
|
| 211 | + $this->enqueued[ $handle ] = $url; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $data = $this->enqueued; |
| 224 | 224 | |
| 225 | - if (null !== $handle && isset($this->enqueued[$handle])) { |
|
| 226 | - $data = $this->enqueued[$handle]; |
|
| 225 | + if (null !== $handle && isset($this->enqueued[ $handle ])) { |
|
| 226 | + $data = $this->enqueued[ $handle ]; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | return $data; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | public function processMarkup($markup) |
| 242 | 242 | { |
| 243 | 243 | $hrefs = $this->parseMarkupForHrefs($markup); |
| 244 | - if (! empty($hrefs)) { |
|
| 244 | + if (!empty($hrefs)) { |
|
| 245 | 245 | $this->setCandidates($hrefs); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $candidates = $this->getCandidates(); |
| 250 | 250 | |
| 251 | 251 | // Bail and return original markup unmodified if we don't have things to do |
| 252 | - if (! $this->hasEnoughElements($candidates)) { |
|
| 252 | + if (!$this->hasEnoughElements($candidates)) { |
|
| 253 | 253 | return $markup; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | protected function filterHrefsFromCandidateLinkNodes(\DOMNodeList $nodes) |
| 291 | 291 | { |
| 292 | - $hrefs = []; |
|
| 292 | + $hrefs = [ ]; |
|
| 293 | 293 | |
| 294 | 294 | foreach ($nodes as $node) { |
| 295 | 295 | if ($this->isCandidateLink($node)) { |
| 296 | - $hrefs[] = $node->getAttribute('href'); |
|
| 296 | + $hrefs[ ] = $node->getAttribute('href'); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | |
| 366 | 366 | // Start our own buffering |
| 367 | - $started = ob_start([$this, 'endBuffering']); |
|
| 367 | + $started = ob_start([ $this, 'endBuffering' ]); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return $started; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | public function endBuffering($markup) |
| 374 | 374 | { |
| 375 | 375 | // Bail early on things we don't want to parse |
| 376 | - if (! $this->isMarkupDoable($markup)) { |
|
| 376 | + if (!$this->isMarkupDoable($markup)) { |
|
| 377 | 377 | return $markup; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $html5 = Utils::hasHtml5Doctype($content); |
| 457 | 457 | $xsl = Utils::hasXslStylesheet($content); |
| 458 | 458 | |
| 459 | - return (($html || $html5) && ! $xsl); |
|
| 459 | + return (($html || $html5) && !$xsl); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -7,19 +7,19 @@ discard block |
||
| 7 | 7 | class GoogleFontsCollection |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $links = []; |
|
| 10 | + protected $links = [ ]; |
|
| 11 | 11 | |
| 12 | - protected $texts = []; |
|
| 12 | + protected $texts = [ ]; |
|
| 13 | 13 | |
| 14 | - protected $complete = []; |
|
| 14 | + protected $complete = [ ]; |
|
| 15 | 15 | |
| 16 | - protected $subsetsMap = []; |
|
| 16 | + protected $subsetsMap = [ ]; |
|
| 17 | 17 | |
| 18 | - protected $namedSizes = []; |
|
| 18 | + protected $namedSizes = [ ]; |
|
| 19 | 19 | |
| 20 | - public function __construct(array $urls = []) |
|
| 20 | + public function __construct(array $urls = [ ]) |
|
| 21 | 21 | { |
| 22 | - if (! empty($urls)) { |
|
| 22 | + if (!empty($urls)) { |
|
| 23 | 23 | foreach ($urls as $url) { |
| 24 | 24 | $this->add($url); |
| 25 | 25 | } |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $this->addLink($url); |
| 32 | 32 | |
| 33 | - $params = []; |
|
| 33 | + $params = [ ]; |
|
| 34 | 34 | parse_str(parse_url($url, PHP_URL_QUERY), $params); |
| 35 | 35 | |
| 36 | - $bucket = isset($params['text']) ? 'text' : 'complete'; |
|
| 36 | + $bucket = isset($params[ 'text' ]) ? 'text' : 'complete'; |
|
| 37 | 37 | |
| 38 | 38 | $fontstrings = $this->buildFontStringsFromQueryParams($params); |
| 39 | 39 | foreach ($fontstrings as $font) { |
| 40 | 40 | $this->addFontFromString($font, $bucket); |
| 41 | 41 | if ('text' === $bucket) { |
| 42 | 42 | $font_family = explode(':', $font); |
| 43 | - $this->addTextFont($font_family[0], Utils::httpsify($url)); |
|
| 43 | + $this->addTextFont($font_family[ 0 ], Utils::httpsify($url)); |
|
| 44 | 44 | } else { |
| 45 | 45 | $this->addComplete($font); |
| 46 | 46 | } |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | $subsets = $font->getSubsetsString(); |
| 68 | 68 | |
| 69 | 69 | // Add to bucket list |
| 70 | - $this->fonts[$bucket][] = $font; |
|
| 70 | + $this->fonts[ $bucket ][ ] = $font; |
|
| 71 | 71 | |
| 72 | 72 | // Keeping a separate map of names => subsets for webfontloader purposes |
| 73 | - if (! array_key_exists($name, $this->subsetsMap)) { |
|
| 73 | + if (!array_key_exists($name, $this->subsetsMap)) { |
|
| 74 | 74 | // Nothing found yet, create a new key |
| 75 | - $this->subsetsMap[$name] = $subsets; |
|
| 75 | + $this->subsetsMap[ $name ] = $subsets; |
|
| 76 | 76 | } else { |
| 77 | 77 | // Something is in there already, append to that. |
| 78 | 78 | // Existing subsetsMap[$name] might not be an array |
| 79 | - if (! is_array($this->subsetsMap[$name])) { |
|
| 80 | - $this->subsetsMap[$name] = (array) $this->subsetsMap[$name]; |
|
| 79 | + if (!is_array($this->subsetsMap[ $name ])) { |
|
| 80 | + $this->subsetsMap[ $name ] = (array) $this->subsetsMap[ $name ]; |
|
| 81 | 81 | } |
| 82 | - $this->subsetsMap[$name] = array_merge($this->subsetsMap[$name], (array) $subsets); |
|
| 82 | + $this->subsetsMap[ $name ] = array_merge($this->subsetsMap[ $name ], (array) $subsets); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Deduplicate values and don't sort the subsets map |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | protected function addTextFont($name, $url) |
| 101 | 101 | { |
| 102 | - $this->texts['name'][] = $name; |
|
| 103 | - $this->texts['url'][] = $url; |
|
| 102 | + $this->texts[ 'name' ][ ] = $name; |
|
| 103 | + $this->texts[ 'url' ][ ] = $url; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function addComplete($fontstring) |
| 107 | 107 | { |
| 108 | - $this->complete[] = $fontstring; |
|
| 108 | + $this->complete[ ] = $fontstring; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | protected function addLink($url) |
| 112 | 112 | { |
| 113 | - $this->links[] = $url; |
|
| 113 | + $this->links[ ] = $url; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function getOriginalLinks() |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | public function hasText() |
| 122 | 122 | { |
| 123 | - return (! empty($this->texts)); |
|
| 123 | + return (!empty($this->texts)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function getTextUrls() |
| 130 | 130 | { |
| 131 | - $urls = []; |
|
| 131 | + $urls = [ ]; |
|
| 132 | 132 | |
| 133 | 133 | if ($this->hasText()) { |
| 134 | - $urls = $this->texts['url']; |
|
| 134 | + $urls = $this->texts[ 'url' ]; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return $urls; |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function getTextNames() |
| 144 | 144 | { |
| 145 | - return $this->texts['name']; |
|
| 145 | + return $this->texts[ 'name' ]; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function getFonts() |
| 149 | 149 | { |
| 150 | - return $this->fonts['complete']; |
|
| 150 | + return $this->fonts[ 'complete' ]; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function getFontsText() |
| 154 | 154 | { |
| 155 | - return $this->fonts['text']; |
|
| 155 | + return $this->fonts[ 'text' ]; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function getCombinedUrl() |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | public function getSubsets() |
| 169 | 169 | { |
| 170 | - $subsets = []; |
|
| 170 | + $subsets = [ ]; |
|
| 171 | 171 | |
| 172 | 172 | $fonts = $this->getFonts(); |
| 173 | 173 | foreach ($fonts as $font) { |
| 174 | - $subsets[] = $font->getSubsets(); |
|
| 174 | + $subsets[ ] = $font->getSubsets(); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $subsets = Utils::arrayFlattenIterative($subsets); |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function buildNamedsizesMap() |
| 186 | 186 | { |
| 187 | - $fonts = []; |
|
| 187 | + $fonts = [ ]; |
|
| 188 | 188 | |
| 189 | 189 | foreach ($this->getFonts() as $font) { |
| 190 | 190 | $name = $font->getName(); |
| 191 | - if (! array_key_exists($name, $fonts)) { |
|
| 192 | - $fonts[$name] = $font->getSizes(); |
|
| 191 | + if (!array_key_exists($name, $fonts)) { |
|
| 192 | + $fonts[ $name ] = $font->getSizes(); |
|
| 193 | 193 | } else { |
| 194 | - $fonts[$name] = array_merge($fonts[$name], $font->getSizes()); |
|
| 194 | + $fonts[ $name ] = array_merge($fonts[ $name ], $font->getSizes()); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function buildFontStringsFromQueryParams(array $params) |
| 217 | 217 | { |
| 218 | - $fonts = []; |
|
| 218 | + $fonts = [ ]; |
|
| 219 | 219 | |
| 220 | - foreach (explode('|', $params['family']) as $family) { |
|
| 220 | + foreach (explode('|', $params[ 'family' ]) as $family) { |
|
| 221 | 221 | $font = $this->parseFontStringName($family, $params); |
| 222 | - if (! empty($font)) { |
|
| 223 | - $fonts[] = $font; |
|
| 222 | + if (!empty($font)) { |
|
| 223 | + $fonts[ ] = $font; |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | $subset = false; |
| 239 | 239 | $family = explode(':', $family); |
| 240 | 240 | |
| 241 | - if (isset($params['subset'])) { |
|
| 241 | + if (isset($params[ 'subset' ])) { |
|
| 242 | 242 | // Use the found subset query parameter |
| 243 | - $subset = $params['subset']; |
|
| 244 | - } elseif (isset($family[2])) { |
|
| 243 | + $subset = $params[ 'subset' ]; |
|
| 244 | + } elseif (isset($family[ 2 ])) { |
|
| 245 | 245 | // Use the subset in the family string if present |
| 246 | - $subset = $family[2]; |
|
| 246 | + $subset = $family[ 2 ]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // $family can have a lot of thing specified with separators etc. |
@@ -263,19 +263,19 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | protected function validateFontStringParts(array $family, $subset = false) |
| 265 | 265 | { |
| 266 | - $parts = []; |
|
| 266 | + $parts = [ ]; |
|
| 267 | 267 | |
| 268 | 268 | // First part is the font name, which should always be present |
| 269 | - $parts[] = $family[0]; |
|
| 269 | + $parts[ ] = $family[ 0 ]; |
|
| 270 | 270 | |
| 271 | 271 | // Check if sizes are specified |
| 272 | - if (isset($family[1]) && strlen($family[1]) > 0) { |
|
| 273 | - $parts[] = $family[1]; |
|
| 272 | + if (isset($family[ 1 ]) && strlen($family[ 1 ]) > 0) { |
|
| 273 | + $parts[ ] = $family[ 1 ]; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Add the subset if specified |
| 277 | 277 | if ($subset) { |
| 278 | - $parts[] = $subset; |
|
| 278 | + $parts[ ] = $subset; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | return $parts; |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | protected $name = ''; |
| 9 | 9 | |
| 10 | - protected $sizes = []; |
|
| 10 | + protected $sizes = [ ]; |
|
| 11 | 11 | |
| 12 | - protected $subsets = []; |
|
| 12 | + protected $subsets = [ ]; |
|
| 13 | 13 | |
| 14 | - public function __construct($name, array $sizes = [], array $subsets = []) |
|
| 14 | + public function __construct($name, array $sizes = [ ], array $subsets = [ ]) |
|
| 15 | 15 | { |
| 16 | 16 | $this->setName($name); |
| 17 | 17 | $this->setSizes($sizes); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | public static function fromString($fontstring) |
| 100 | 100 | { |
| 101 | 101 | $parts = explode(':', $fontstring); |
| 102 | - $font = new self($parts[0]); |
|
| 102 | + $font = new self($parts[ 0 ]); |
|
| 103 | 103 | |
| 104 | - if (isset($parts[1])) { |
|
| 105 | - $font->setSizes($parts[1]); |
|
| 104 | + if (isset($parts[ 1 ])) { |
|
| 105 | + $font->setSizes($parts[ 1 ]); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if (isset($parts[2])) { |
|
| 109 | - $font->setSubsets($parts[2]); |
|
| 108 | + if (isset($parts[ 2 ])) { |
|
| 109 | + $font->setSubsets($parts[ 2 ]); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $font; |