@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function factory($path) : PHPFile |
| 34 | 34 | { |
| 35 | - if($path instanceof self) { |
|
| 35 | + if ($path instanceof self) { |
|
| 36 | 36 | return $path; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $instance = self::createInstance($path); |
| 40 | 40 | |
| 41 | - if($instance instanceof self) { |
|
| 41 | + if ($instance instanceof self) { |
|
| 42 | 42 | return $instance; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function checkSyntax() |
| 61 | 61 | { |
| 62 | - if(!FileHelper::canMakePHPCalls()) |
|
| 62 | + if (!FileHelper::canMakePHPCalls()) |
|
| 63 | 63 | { |
| 64 | 64 | return true; |
| 65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | // when the validation is successful, the first entry |
| 72 | 72 | // in the array contains the success message. When it |
| 73 | 73 | // is invalid, the first entry is always empty. |
| 74 | - if(!empty($output[0])) { |
|
| 74 | + if (!empty($output[0])) { |
|
| 75 | 75 | return true; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -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,12 +185,12 @@ 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 | } |
| 192 | 192 | |
| 193 | - public function saveJSONFile(array $data, string $fileName, bool $pretty=false) : JSONFile |
|
| 193 | + public function saveJSONFile(array $data, string $fileName, bool $pretty = false) : JSONFile |
|
| 194 | 194 | { |
| 195 | 195 | return FileHelper::saveAsJSON($data, $this.'/'.$fileName, $pretty); |
| 196 | 196 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | $this->subject = $subject; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setRemoveDuplicates(bool $remove=true, bool $caseInsensitive=false) : self |
|
| 30 | + public function setRemoveDuplicates(bool $remove = true, bool $caseInsensitive = false) : self |
|
| 31 | 31 | { |
| 32 | 32 | $this->removeDuplicates = $remove; |
| 33 | 33 | $this->duplicatesCaseInsensitive = $caseInsensitive; |
| 34 | 34 | return $this; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function setSorting(bool $sorting=true) : self |
|
| 37 | + public function setSorting(bool $sorting = true) : self |
|
| 38 | 38 | { |
| 39 | 39 | $this->sorting = $sorting; |
| 40 | 40 | return $this; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $words = $this->filterEmpty($words); |
| 54 | 54 | |
| 55 | - if($this->removeDuplicates) { |
|
| 55 | + if ($this->removeDuplicates) { |
|
| 56 | 56 | $words = $this->filterDuplicates($words); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if($this->sorting) { |
|
| 59 | + if ($this->sorting) { |
|
| 60 | 60 | usort($words, 'strnatcasecmp'); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | private function filterDuplicates(array $words) : array |
| 67 | 67 | { |
| 68 | - if($this->duplicatesCaseInsensitive) { |
|
| 68 | + if ($this->duplicatesCaseInsensitive) { |
|
| 69 | 69 | return $this->filterDuplicatesCaseInsensitive($words); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | return array_intersect_key( |
| 78 | 78 | $array, |
| 79 | - array_unique( array_map( "strtolower", $array ) ) |
|
| 79 | + array_unique(array_map("strtolower", $array)) |
|
| 80 | 80 | ); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $keep = array(); |
| 90 | 90 | |
| 91 | - foreach($words as $word) |
|
| 91 | + foreach ($words as $word) |
|
| 92 | 92 | { |
| 93 | - if(empty($word)) { |
|
| 93 | + if (empty($word)) { |
|
| 94 | 94 | continue; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if(mb_strlen($word) < $this->minWordLength) { |
|
| 97 | + if (mb_strlen($word) < $this->minWordLength) { |
|
| 98 | 98 | continue; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function setMinWords(int $min) : self |
| 123 | 123 | { |
| 124 | 124 | // Avoid a reset if the value is the same |
| 125 | - if($this->minWords === $min) |
|
| 125 | + if ($this->minWords === $min) |
|
| 126 | 126 | { |
| 127 | 127 | return $this; |
| 128 | 128 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | private function detect() : void |
| 144 | 144 | { |
| 145 | - if($this->detected) { |
|
| 145 | + if ($this->detected) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -150,15 +150,15 @@ discard block |
||
| 150 | 150 | $this->found = array(); |
| 151 | 151 | $this->count = 0; |
| 152 | 152 | |
| 153 | - foreach(self::$words as $word) |
|
| 153 | + foreach (self::$words as $word) |
|
| 154 | 154 | { |
| 155 | - if(stripos($this->subject, $word) !== false) |
|
| 155 | + if (stripos($this->subject, $word) !== false) |
|
| 156 | 156 | { |
| 157 | 157 | $this->count++; |
| 158 | 158 | $this->found[] = $word; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($this->count >= $this->minWords) { |
|
| 161 | + if ($this->count >= $this->minWords) { |
|
| 162 | 162 | break; |
| 163 | 163 | } |
| 164 | 164 | } |