11<?php
22
3+ /*
4+ * This file is part of the alfred-github-workflow package.
5+ *
6+ * (c) Gregor Harlan
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
312class Item
413{
514 private $ randomUid = false ;
@@ -19,7 +28,7 @@ class Item
1928
2029 public static function create ()
2130 {
22- return new self ;
31+ return new self () ;
2332 }
2433
2534 public function randomUid ()
@@ -99,7 +108,7 @@ public function match($query)
99108 return false ;
100109 }
101110 if ($ i === $ k ) {
102- $ this ->sameChars ++ ;
111+ ++ $ this ->sameChars ;
103112 }
104113 }
105114 $ this ->missingChars = strlen ($ comparator ) - $ queryLength ;
@@ -119,6 +128,7 @@ public function compare(self $another)
119128
120129 /**
121130 * @param self[] $items
131+ *
122132 * @return string
123133 */
124134 public static function toXml (array $ items , $ enterprise , $ hotkey , $ baseUrl )
@@ -127,19 +137,19 @@ public static function toXml(array $items, $enterprise, $hotkey, $baseUrl)
127137 $ prefix = $ hotkey ? '' : ' ' ;
128138 foreach ($ items as $ item ) {
129139 $ c = $ xml ->addChild ('item ' );
130- $ title = $ item ->prefix . $ item ->title ;
131- $ c ->addAttribute ('uid ' , $ item ->randomUid ? md5 (time () . $ title ) : md5 ($ title ));
132- if ($ item ->icon && file_exists (__DIR__ . '/icons/ ' . $ item ->icon . '.png ' )) {
133- $ c ->addChild ('icon ' , 'icons/ ' . $ item ->icon . '.png ' );
140+ $ title = $ item ->prefix . $ item ->title ;
141+ $ c ->addAttribute ('uid ' , $ item ->randomUid ? md5 (time (). $ title ) : md5 ($ title ));
142+ if ($ item ->icon && file_exists (__DIR__ . '/icons/ ' . $ item ->icon . '.png ' )) {
143+ $ c ->addChild ('icon ' , 'icons/ ' . $ item ->icon . '.png ' );
134144 } else {
135145 $ c ->addChild ('icon ' , 'icon.png ' );
136146 }
137147 if ($ item ->arg ) {
138148 $ arg = $ item ->arg ;
139149 if ('/ ' === $ arg [0 ]) {
140- $ arg = $ baseUrl . $ arg ;
150+ $ arg = $ baseUrl. $ arg ;
141151 } elseif (false === strpos ($ arg , ':// ' )) {
142- $ arg = ($ enterprise ? 'e ' : '' ) . $ arg ;
152+ $ arg = ($ enterprise ? 'e ' : '' ). $ arg ;
143153 }
144154 $ c ->addAttribute ('arg ' , $ arg );
145155 }
@@ -151,7 +161,7 @@ public static function toXml(array $items, $enterprise, $hotkey, $baseUrl)
151161 } else {
152162 $ autocomplete = $ item ->title ;
153163 }
154- $ c ->addAttribute ('autocomplete ' , $ prefix . ($ item ->prefixOnlyTitle ? $ autocomplete : $ item ->prefix . $ autocomplete ));
164+ $ c ->addAttribute ('autocomplete ' , $ prefix. ($ item ->prefixOnlyTitle ? $ autocomplete : $ item ->prefix . $ autocomplete ));
155165 }
156166 if (!$ item ->valid ) {
157167 $ c ->addAttribute ('valid ' , 'no ' );
0 commit comments