Passed
Push — master ( 091505...2927d0 )
by zyt
02:52 queued 01:13
created
src/GoogleFontsCollection.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@  discard block
 block discarded – undo
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 $fonts = [];
16
+    protected $fonts = [ ];
17 17
 
18
-    protected $subsetsMap = [];
18
+    protected $subsetsMap = [ ];
19 19
 
20
-    protected $namedSizes = [];
20
+    protected $namedSizes = [ ];
21 21
 
22
-    public function __construct(array $urls = [])
22
+    public function __construct(array $urls = [ ])
23 23
     {
24
-        if (! empty($urls)) {
24
+        if (!empty($urls)) {
25 25
             foreach ($urls as $url) {
26 26
                 $this->add($url);
27 27
             }
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $this->addLink($url);
34 34
 
35
-        $params = [];
35
+        $params = [ ];
36 36
         parse_str(parse_url($url, PHP_URL_QUERY), $params);
37 37
 
38
-        $bucket = isset($params['text']) ? 'text' : 'complete';
38
+        $bucket = isset($params[ 'text' ]) ? 'text' : 'complete';
39 39
 
40 40
         $fontstrings = $this->buildFontStringsFromQueryParams($params);
41 41
         foreach ($fontstrings as $font) {
42 42
             $this->addFontFromString($font, $bucket);
43 43
             if ('text' === $bucket) {
44 44
                 $font_family = explode(':', $font);
45
-                $this->addTextFont($font_family[0], Utils::httpsify($url));
45
+                $this->addTextFont($font_family[ 0 ], Utils::httpsify($url));
46 46
             } else {
47 47
                 $this->addComplete($font);
48 48
             }
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
         $subsets = $font->getSubsetsString();
70 70
 
71 71
         // Add to bucket list
72
-        $this->fonts[$bucket][] = $font;
72
+        $this->fonts[ $bucket ][ ] = $font;
73 73
 
74 74
         // Keeping a separate map of names => subsets for webfontloader purposes
75
-        if (! array_key_exists($name, $this->subsetsMap)) {
75
+        if (!array_key_exists($name, $this->subsetsMap)) {
76 76
             // Nothing found yet, create a new key
77
-            $this->subsetsMap[$name] = $subsets;
77
+            $this->subsetsMap[ $name ] = $subsets;
78 78
         } else {
79 79
             // Something is in there already, merge
80
-            $this->subsetsMap[$name] = array_merge($this->subsetsMap[$name], (array) $subsets);
80
+            $this->subsetsMap[ $name ] = array_merge($this->subsetsMap[ $name ], (array) $subsets);
81 81
         }
82 82
 
83 83
         // Deduplicate values and don't sort the subsets map
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 
98 98
     protected function addTextFont($name, $url)
99 99
     {
100
-        $this->texts['name'][] = $name;
101
-        $this->texts['url'][]  = $url;
100
+        $this->texts[ 'name' ][ ] = $name;
101
+        $this->texts[ 'url' ][ ]  = $url;
102 102
     }
103 103
 
104 104
     protected function addComplete($fontstring)
105 105
     {
106
-        $this->complete[] = $fontstring;
106
+        $this->complete[ ] = $fontstring;
107 107
     }
108 108
 
109 109
     protected function addLink($url)
110 110
     {
111
-        $this->links[] = $url;
111
+        $this->links[ ] = $url;
112 112
     }
113 113
 
114 114
     public function getOriginalLinks()
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     public function hasText()
120 120
     {
121
-        return (! empty($this->texts));
121
+        return (!empty($this->texts));
122 122
     }
123 123
 
124 124
     /**
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function getTextUrls()
128 128
     {
129
-        $urls = [];
129
+        $urls = [ ];
130 130
 
131 131
         if ($this->hasText()) {
132
-            $urls = $this->texts['url'];
132
+            $urls = $this->texts[ 'url' ];
133 133
         }
134 134
 
135 135
         return $urls;
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function getTextNames()
142 142
     {
143
-        return $this->texts['name'];
143
+        return $this->texts[ 'name' ];
144 144
     }
145 145
 
146 146
     public function getFonts()
147 147
     {
148
-        return $this->fonts['complete'];
148
+        return $this->fonts[ 'complete' ];
149 149
     }
150 150
 
151 151
     public function getFontsText()
152 152
     {
153
-        return $this->fonts['text'];
153
+        return $this->fonts[ 'text' ];
154 154
     }
155 155
 
156 156
     public function getCombinedUrl()
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 
166 166
     public function getSubsets()
167 167
     {
168
-        $subsets = [];
168
+        $subsets = [ ];
169 169
 
170 170
         $fonts = $this->getFonts();
171 171
         foreach ($fonts as $font) {
172
-            $subsets[] = $font->getSubsets();
172
+            $subsets[ ] = $font->getSubsets();
173 173
         }
174 174
 
175 175
         $subsets = Utils::arrayFlattenIterative($subsets);
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
      */
183 183
     protected function buildNamedsizesMap()
184 184
     {
185
-        $fonts = [];
185
+        $fonts = [ ];
186 186
 
187 187
         foreach ($this->getFonts() as $font) {
188 188
             $name = $font->getName();
189
-            if (! array_key_exists($name, $fonts)) {
190
-                $fonts[$name] = $font->getSizes();
189
+            if (!array_key_exists($name, $fonts)) {
190
+                $fonts[ $name ] = $font->getSizes();
191 191
             } else {
192
-                $fonts[$name] = array_merge($fonts[$name], $font->getSizes());
192
+                $fonts[ $name ] = array_merge($fonts[ $name ], $font->getSizes());
193 193
             }
194 194
         }
195 195
 
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
      */
214 214
     protected function buildFontStringsFromQueryParams(array $params)
215 215
     {
216
-        $fonts = [];
216
+        $fonts = [ ];
217 217
 
218
-        foreach (explode('|', $params['family']) as $family) {
218
+        foreach (explode('|', $params[ 'family' ]) as $family) {
219 219
             $font = $this->parseFontStringName($family, $params);
220
-            if (! empty($font)) {
221
-                $fonts[] = $font;
220
+            if (!empty($font)) {
221
+                $fonts[ ] = $font;
222 222
             }
223 223
         }
224 224
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
         $subset = false;
237 237
         $family = explode(':', $family);
238 238
 
239
-        if (isset($params['subset'])) {
239
+        if (isset($params[ 'subset' ])) {
240 240
             // Use the found subset query parameter
241
-            $subset = $params['subset'];
242
-        } elseif (isset($family[2])) {
241
+            $subset = $params[ 'subset' ];
242
+        } elseif (isset($family[ 2 ])) {
243 243
             // Use the subset in the family string if present
244
-            $subset = $family[2];
244
+            $subset = $family[ 2 ];
245 245
         }
246 246
 
247 247
         // $family can have a lot of thing specified with separators etc.
@@ -261,19 +261,19 @@  discard block
 block discarded – undo
261 261
      */
262 262
     protected function validateFontStringParts(array $family, $subset = false)
263 263
     {
264
-        $parts = [];
264
+        $parts = [ ];
265 265
 
266 266
         // First part is the font name, which should always be present
267
-        $parts[] = $family[0];
267
+        $parts[ ] = $family[ 0 ];
268 268
 
269 269
         // Check if sizes are specified
270
-        if (isset($family[1]) && strlen($family[1]) > 0) {
271
-            $parts[] = $family[1];
270
+        if (isset($family[ 1 ]) && strlen($family[ 1 ]) > 0) {
271
+            $parts[ ] = $family[ 1 ];
272 272
         }
273 273
 
274 274
         // Add the subset if specified
275 275
         if ($subset) {
276
-            $parts[] = $subset;
276
+            $parts[ ] = $subset;
277 277
         }
278 278
 
279 279
         return $parts;
Please login to merge, or discard this patch.