@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | protected bool $value = false; |
| 23 | 23 | |
| 24 | - public function __construct(bool $value=false) |
|
| 24 | + public function __construct(bool $value = false) |
|
| 25 | 25 | { |
| 26 | 26 | $this->value = $value; |
| 27 | 27 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | private function addFont(string $name) : FontFamily |
| 34 | 34 | { |
| 35 | - if(!in_array($name, $this->fonts, true)) |
|
| 35 | + if (!in_array($name, $this->fonts, true)) |
|
| 36 | 36 | { |
| 37 | 37 | $this->fonts[] = $name; |
| 38 | 38 | } |
@@ -33,22 +33,22 @@ discard block |
||
| 33 | 33 | $this->parse(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Retrieves an indexed array with accept mime types |
|
| 38 | - * that the client sent, in the order of preference |
|
| 39 | - * the client specified. |
|
| 40 | - * |
|
| 41 | - * Example: |
|
| 42 | - * |
|
| 43 | - * array( |
|
| 44 | - * 'text/html', |
|
| 45 | - * 'application/xhtml+xml', |
|
| 46 | - * 'image/webp' |
|
| 47 | - * ... |
|
| 48 | - * ) |
|
| 49 | - * |
|
| 50 | - * @return string[] |
|
| 51 | - */ |
|
| 36 | + /** |
|
| 37 | + * Retrieves an indexed array with accept mime types |
|
| 38 | + * that the client sent, in the order of preference |
|
| 39 | + * the client specified. |
|
| 40 | + * |
|
| 41 | + * Example: |
|
| 42 | + * |
|
| 43 | + * array( |
|
| 44 | + * 'text/html', |
|
| 45 | + * 'application/xhtml+xml', |
|
| 46 | + * 'image/webp' |
|
| 47 | + * ... |
|
| 48 | + * ) |
|
| 49 | + * |
|
| 50 | + * @return string[] |
|
| 51 | + */ |
|
| 52 | 52 | public function getMimeStrings() : array |
| 53 | 53 | { |
| 54 | 54 | $result = array(); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | return $result; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | + */ |
|
| 67 | 67 | protected function parse() : void |
| 68 | 68 | { |
| 69 | 69 | // we may be in a CLI environment where the headers |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Splits the "Accept" header string and parses the mime types. |
|
| 80 | - * |
|
| 81 | - * @param string $acceptHeader |
|
| 82 | - * @return AcceptHeader[] |
|
| 83 | - */ |
|
| 78 | + /** |
|
| 79 | + * Splits the "Accept" header string and parses the mime types. |
|
| 80 | + * |
|
| 81 | + * @param string $acceptHeader |
|
| 82 | + * @return AcceptHeader[] |
|
| 83 | + */ |
|
| 84 | 84 | protected function parseHeader(string $acceptHeader) : array |
| 85 | 85 | { |
| 86 | 86 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | return $accept; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Parses a single mime type entry. |
|
| 102 | - * |
|
| 103 | - * @param int $i The position in the "Accept" string |
|
| 104 | - * @param string $mime The mime type |
|
| 105 | - * @return AcceptHeader |
|
| 106 | - */ |
|
| 100 | + /** |
|
| 101 | + * Parses a single mime type entry. |
|
| 102 | + * |
|
| 103 | + * @param int $i The position in the "Accept" string |
|
| 104 | + * @param string $mime The mime type |
|
| 105 | + * @return AcceptHeader |
|
| 106 | + */ |
|
| 107 | 107 | protected function parseEntry(int $i, string $mime) : AcceptHeader |
| 108 | 108 | { |
| 109 | 109 | $quality = 0; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $result = array(); |
| 55 | 55 | |
| 56 | - foreach($this->headers as $header) |
|
| 56 | + foreach ($this->headers as $header) |
|
| 57 | 57 | { |
| 58 | 58 | $result[] = $header->getMimeType(); |
| 59 | 59 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | // we may be in a CLI environment where the headers |
| 70 | 70 | // are not populated. |
| 71 | - if(!isset($_SERVER['HTTP_ACCEPT'])) { |
|
| 71 | + if (!isset($_SERVER['HTTP_ACCEPT'])) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $accept = array(); |
| 89 | 89 | |
| 90 | - foreach($tokens as $i => $term) |
|
| 90 | + foreach ($tokens as $i => $term) |
|
| 91 | 91 | { |
| 92 | 92 | $accept[] = $this->parseEntry($i, $term); |
| 93 | 93 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $quality = 0; |
| 110 | 110 | $params = array(); |
| 111 | 111 | |
| 112 | - if(strpos($mime, ';') !== false) |
|
| 112 | + if (strpos($mime, ';') !== false) |
|
| 113 | 113 | { |
| 114 | 114 | $parts = explode(';', $mime); |
| 115 | 115 | $mime = (string)array_shift($parts); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // like a URL query string if separated by ampersands; |
| 119 | 119 | $params = ConvertHelper::parseQueryString(implode('&', $parts)); |
| 120 | 120 | |
| 121 | - if(isset($params['q'])) |
|
| 121 | + if (isset($params['q'])) |
|
| 122 | 122 | { |
| 123 | 123 | $quality = (double)$params['q']; |
| 124 | 124 | } |
@@ -148,14 +148,12 @@ |
||
| 148 | 148 | if ($diff > 0) |
| 149 | 149 | { |
| 150 | 150 | $diff = 1; |
| 151 | - } |
|
| 152 | - else |
|
| 151 | + } else |
|
| 153 | 152 | { |
| 154 | 153 | if ($diff < 0) |
| 155 | 154 | { |
| 156 | 155 | $diff = -1; |
| 157 | - } |
|
| 158 | - else |
|
| 156 | + } else |
|
| 159 | 157 | { |
| 160 | 158 | /* tie-breaker: first listed item wins */ |
| 161 | 159 | $diff = $a->getPosition() - $b->getPosition(); |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | */ |
| 92 | 92 | public function offsetSet($offset, $value) : void |
| 93 | 93 | { |
| 94 | - if(isset($this->data[$offset]) && gettype($this->data[$offset]) === gettype($value)) { |
|
| 94 | + if (isset($this->data[$offset]) && gettype($this->data[$offset]) === gettype($value)) { |
|
| 95 | 95 | $this->data[$offset] = $value; |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $pathString = AbstractPathInfo::type2string($path); |
| 32 | 32 | |
| 33 | - if(!isset(self::$infoCache[$pathString])) |
|
| 33 | + if (!isset(self::$infoCache[$pathString])) |
|
| 34 | 34 | { |
| 35 | 35 | self::$infoCache[$pathString] = new FolderInfo($pathString); |
| 36 | 36 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | parent::__construct($path); |
| 61 | 61 | |
| 62 | - if(!self::is_dir($this->path)) |
|
| 62 | + if (!self::is_dir($this->path)) |
|
| 63 | 63 | { |
| 64 | 64 | throw new FileHelper_Exception( |
| 65 | 65 | 'Not a folder', |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $path = trim($path); |
| 83 | 83 | |
| 84 | - if($path === '' || $path === '.' || $path === '..') |
|
| 84 | + if ($path === '' || $path === '.' || $path === '..') |
|
| 85 | 85 | { |
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(is_dir($path)) |
|
| 89 | + if (is_dir($path)) |
|
| 90 | 90 | { |
| 91 | 91 | return true; |
| 92 | 92 | } |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function delete() : FolderInfo |
| 106 | 106 | { |
| 107 | - if(!$this->exists()) |
|
| 107 | + if (!$this->exists()) |
|
| 108 | 108 | { |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if(rmdir($this->path)) |
|
| 112 | + if (rmdir($this->path)) |
|
| 113 | 113 | { |
| 114 | 114 | return $this; |
| 115 | 115 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function create() : FolderInfo |
| 137 | 137 | { |
| 138 | - if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
| 138 | + if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
| 139 | 139 | { |
| 140 | 140 | return $this; |
| 141 | 141 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | return FileHelper::createFolder($this->getPath().'/'.$name); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - public function saveFile(string $fileName, string $content='') : FileInfo |
|
| 188 | + public function saveFile(string $fileName, string $content = '') : FileInfo |
|
| 189 | 189 | { |
| 190 | 190 | return FileHelper::saveFile($this.'/'.$fileName, $content); |
| 191 | 191 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @return JSONFile |
| 198 | 198 | * @throws FileHelper_Exception |
| 199 | 199 | */ |
| 200 | - public function saveJSONFile(array $data, string $fileName, bool $pretty=false) : JSONFile |
|
| 200 | + public function saveJSONFile(array $data, string $fileName, bool $pretty = false) : JSONFile |
|
| 201 | 201 | { |
| 202 | 202 | return FileHelper::saveAsJSON($data, $this.'/'.$fileName, $pretty); |
| 203 | 203 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param bool $enable Whether to turn it on or off. |
| 36 | 36 | * @return URLInfo_Normalizer |
| 37 | 37 | */ |
| 38 | - public function enableAuth(bool $enable=true) : URLInfo_Normalizer |
|
| 38 | + public function enableAuth(bool $enable = true) : URLInfo_Normalizer |
|
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
@@ -82,48 +82,48 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | protected function renderAuth(string $normalized) : string |
| 84 | 84 | { |
| 85 | - if(!$this->auth || !$this->info->hasUsername()) { |
|
| 85 | + if (!$this->auth || !$this->info->hasUsername()) { |
|
| 86 | 86 | return $normalized; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 89 | + return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | protected function renderPort(string $normalized) : string |
| 93 | 93 | { |
| 94 | - if(!$this->info->hasPort()) { |
|
| 94 | + if (!$this->info->hasPort()) { |
|
| 95 | 95 | return $normalized; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - return $normalized . ':'.$this->info->getPort(); |
|
| 98 | + return $normalized.':'.$this->info->getPort(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | protected function renderPath(string $normalized) : string |
| 102 | 102 | { |
| 103 | - if(!$this->info->hasPath()) { |
|
| 103 | + if (!$this->info->hasPath()) { |
|
| 104 | 104 | return $normalized; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - return $normalized . $this->info->getPath(); |
|
| 107 | + return $normalized.$this->info->getPath(); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | protected function renderParams(string $normalized) : string |
| 111 | 111 | { |
| 112 | 112 | $params = $this->info->getParams(); |
| 113 | 113 | |
| 114 | - if(empty($params)) { |
|
| 114 | + if (empty($params)) { |
|
| 115 | 115 | return $normalized; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return $normalized . '?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 118 | + return $normalized.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | protected function renderFragment(string $normalized) : string |
| 122 | 122 | { |
| 123 | - if(!$this->info->hasFragment()) { |
|
| 123 | + if (!$this->info->hasFragment()) { |
|
| 124 | 124 | return $normalized; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return $normalized . '#'.$this->info->getFragment(); |
|
| 127 | + return $normalized.'#'.$this->info->getFragment(); |
|
| 128 | 128 | } |
| 129 | 129 | } |