@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use Ffcms\Core\Helper\FileSystem\Normalize; |
| 9 | 9 | use Ffcms\Core\Helper\Type\Any; |
| 10 | 10 | use Ffcms\Core\Helper\Type\Arr; |
| 11 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 12 | 11 | use Ffcms\Core\Helper\Type\Str; |
| 13 | 12 | |
| 14 | 13 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | continue; |
| 71 | 71 | } |
| 72 | 72 | // check initialize conditions (equals to $exist) |
| 73 | - if (File::exist($this->dir . '/' . $migration)) { |
|
| 73 | + if (File::exist($this->dir.'/'.$migration)) { |
|
| 74 | 74 | if (Arr::in($fullName, $dbmigrations) === $exist) { |
| 75 | 75 | $found[] = $migration; |
| 76 | 76 | } |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // check if migration file is exists |
| 103 | - if (!File::exist($this->dir . '/' . $file)) |
|
| 103 | + if (!File::exist($this->dir.'/'.$file)) |
|
| 104 | 104 | return false; |
| 105 | 105 | |
| 106 | 106 | // check if migration file located in extend directory and copy to default |
| 107 | 107 | if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) { |
| 108 | - File::copy($this->dir . DIRECTORY_SEPARATOR . $file, static::DEFAULT_DIR . DIRECTORY_SEPARATOR . $file); |
|
| 108 | + File::copy($this->dir.DIRECTORY_SEPARATOR.$file, static::DEFAULT_DIR.DIRECTORY_SEPARATOR.$file); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // include migration and get class name |
| 112 | - File::inc($this->dir . '/' . $file, false, false); |
|
| 112 | + File::inc($this->dir.'/'.$file, false, false); |
|
| 113 | 113 | $fullName = Str::cleanExtension($file); |
| 114 | 114 | $class = Str::firstIn($fullName, '-'); |
| 115 | 115 | |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // check if exists |
| 147 | - if (!File::exist($this->dir . '/' . $file)) |
|
| 147 | + if (!File::exist($this->dir.'/'.$file)) |
|
| 148 | 148 | return false; |
| 149 | 149 | |
| 150 | - File::inc($this->dir . '/' . $file, false, false); |
|
| 150 | + File::inc($this->dir.'/'.$file, false, false); |
|
| 151 | 151 | $fullName = Str::cleanExtension($file); |
| 152 | 152 | $class = Str::firstIn($fullName, '-'); |
| 153 | 153 | |
@@ -30,14 +30,16 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct(?string $dir = null, ?string $connectionName = null) |
| 32 | 32 | { |
| 33 | - if ($dir === null) |
|
| 34 | - $dir = static::DEFAULT_DIR; |
|
| 33 | + if ($dir === null) { |
|
| 34 | + $dir = static::DEFAULT_DIR; |
|
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | $this->dir = rtrim($dir, '/'); |
| 37 | 38 | $this->connection = $connectionName; |
| 38 | 39 | |
| 39 | - if ($this->dir !== static::DEFAULT_DIR) |
|
| 40 | - $this->customDir = true; |
|
| 40 | + if ($this->dir !== static::DEFAULT_DIR) { |
|
| 41 | + $this->customDir = true; |
|
| 42 | + } |
|
| 41 | 43 | } |
| 42 | 44 | |
| 43 | 45 | /** |
@@ -50,16 +52,18 @@ discard block |
||
| 50 | 52 | { |
| 51 | 53 | // initialize db migration record |
| 52 | 54 | $records = new Migration(); |
| 53 | - if ($this->connection !== null) |
|
| 54 | - $records->setConnection($this->connection); |
|
| 55 | + if ($this->connection !== null) { |
|
| 56 | + $records->setConnection($this->connection); |
|
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | // get installed migrations |
| 57 | 60 | $dbmigrations = Arr::pluck('migration', $records->get()->toArray()); |
| 58 | 61 | |
| 59 | 62 | // list migrations |
| 60 | 63 | $migrations = File::listFiles($this->dir, ['.php'], true); |
| 61 | - if (!Any::isArray($migrations) || count($migrations) < 1) |
|
| 62 | - return false; |
|
| 64 | + if (!Any::isArray($migrations) || count($migrations) < 1) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | $found = false; |
| 65 | 69 | foreach ($migrations as $migration) { |
@@ -100,8 +104,9 @@ discard block |
||
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | // check if migration file is exists |
| 103 | - if (!File::exist($this->dir . '/' . $file)) |
|
| 104 | - return false; |
|
| 107 | + if (!File::exist($this->dir . '/' . $file)) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 105 | 110 | |
| 106 | 111 | // check if migration file located in extend directory and copy to default |
| 107 | 112 | if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) { |
@@ -114,8 +119,9 @@ discard block |
||
| 114 | 119 | $class = Str::firstIn($fullName, '-'); |
| 115 | 120 | |
| 116 | 121 | // check if class is instance of migration interface |
| 117 | - if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true)) |
|
| 118 | - return false; |
|
| 122 | + if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true)) { |
|
| 123 | + return false; |
|
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | // implement migration |
| 121 | 127 | $init = new $class($fullName, $this->connection); |
@@ -144,8 +150,9 @@ discard block |
||
| 144 | 150 | } |
| 145 | 151 | |
| 146 | 152 | // check if exists |
| 147 | - if (!File::exist($this->dir . '/' . $file)) |
|
| 148 | - return false; |
|
| 153 | + if (!File::exist($this->dir . '/' . $file)) { |
|
| 154 | + return false; |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | File::inc($this->dir . '/' . $file, false, false); |
| 151 | 158 | $fullName = Str::cleanExtension($file); |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Ffcms\Core\App; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Any; |
| 7 | 7 | use Ffcms\Core\Helper\Type\Arr; |
| 8 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 9 | 8 | use Ffcms\Core\Helper\Type\Str; |
| 10 | 9 | use Symfony\Component\HttpFoundation\RedirectResponse as Redirect; |
| 11 | 10 | use Symfony\Component\HttpFoundation\Request as FoundationRequest; |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $basePath = trim(App::$Properties->get('basePath'), '/'); |
| 62 | 62 | if ($basePath !== null && Str::length($basePath) > 0) { |
| 63 | - $basePath = '/' . $basePath; |
|
| 63 | + $basePath = '/'.$basePath; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!defined('env_no_uri') || env_no_uri === false) { |
| 67 | - $basePath .= '/' . strtolower(env_name); |
|
| 67 | + $basePath .= '/'.strtolower(env_name); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // we never try to use path's without friendly url's |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | } else { |
| 91 | 91 | // try to find language in pathway |
| 92 | 92 | foreach (App::$Properties->get('languages') as $lang) { |
| 93 | - if (Str::startsWith('/' . $lang, $this->getPathInfo())) { |
|
| 93 | + if (Str::startsWith('/'.$lang, $this->getPathInfo())) { |
|
| 94 | 94 | $this->language = $lang; |
| 95 | 95 | $this->languageInPath = true; |
| 96 | 96 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | // parse query string |
| 118 | 118 | $queryString = null; |
| 119 | 119 | if (count($this->query->all()) > 0) { |
| 120 | - $queryString = '?' . http_build_query($this->query->all()); |
|
| 120 | + $queryString = '?'.http_build_query($this->query->all()); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // build response with redirect to language-based path |
| 124 | - $response = new Redirect($this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString); |
|
| 124 | + $response = new Redirect($this->getSchemeAndHttpHost().$this->basePath.'/'.$userLang.$this->getPathInfo().$queryString); |
|
| 125 | 125 | $response->send(); |
| 126 | 126 | exit(); |
| 127 | 127 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if (array_key_exists($pathway, $routing['Redirect'])) { |
| 181 | 181 | $target = $this->getSchemeAndHttpHost(); // . $this->getBasePath() . '/' . rtrim($routing['Redirect'][$pathway], '/'); |
| 182 | 182 | if ($this->getBasePath() !== null && !Str::likeEmpty($this->getBasePath())) { |
| 183 | - $target .= '/' . $this->getBasePath(); |
|
| 183 | + $target .= '/'.$this->getBasePath(); |
|
| 184 | 184 | } |
| 185 | 185 | $target .= rtrim($routing['Redirect'][$pathway], '/'); |
| 186 | 186 | $redirect = new Redirect($target); |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | // find "new path" as binding uri slug |
| 207 | 207 | $binding = array_search($pathway, $map, true); |
| 208 | 208 | // build url to redirection |
| 209 | - $url = $this->getSchemeAndHttpHost() . $this->getBasePath() . '/'; |
|
| 209 | + $url = $this->getSchemeAndHttpHost().$this->getBasePath().'/'; |
|
| 210 | 210 | if (App::$Properties->get('multiLanguage')) { |
| 211 | - $url .= $this->language . '/'; |
|
| 211 | + $url .= $this->language.'/'; |
|
| 212 | 212 | } |
| 213 | 213 | $url .= ltrim($binding, '/'); |
| 214 | 214 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | { |
| 303 | 303 | $route = $this->languageInPath ? Str::sub(parent::getPathInfo(), Str::length($this->language) + 1) : parent::getPathInfo(); |
| 304 | 304 | if (!Str::startsWith('/', $route)) |
| 305 | - $route = '/' . $route; |
|
| 305 | + $route = '/'.$route; |
|
| 306 | 306 | return $route; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | public function getFullUrl(): string |
| 468 | 468 | { |
| 469 | - return $this->getSchemeAndHttpHost() . $this->getRequestUri(); |
|
| 469 | + return $this->getSchemeAndHttpHost().$this->getRequestUri(); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -141,18 +141,21 @@ discard block |
||
| 141 | 141 | $routing = App::$Properties->getAll('Routing'); |
| 142 | 142 | |
| 143 | 143 | // try to work with static aliases |
| 144 | - if (Any::isArray($routing) && isset($routing['Alias'], $routing['Alias'][env_name])) |
|
| 145 | - $pathway = $this->findStaticAliases($routing['Alias'][env_name], $pathway); |
|
| 144 | + if (Any::isArray($routing) && isset($routing['Alias'], $routing['Alias'][env_name])) { |
|
| 145 | + $pathway = $this->findStaticAliases($routing['Alias'][env_name], $pathway); |
|
| 146 | + } |
|
| 146 | 147 | |
| 147 | 148 | $this->setPathdata(explode('/', trim($pathway, '/'))); |
| 148 | 149 | |
| 149 | 150 | // set default controller and action for undefined data |
| 150 | - if (!$this->action) |
|
| 151 | - $this->action = 'Index'; |
|
| 151 | + if (!$this->action) { |
|
| 152 | + $this->action = 'Index'; |
|
| 153 | + } |
|
| 152 | 154 | |
| 153 | 155 | // empty or contains backslashes? set to main |
| 154 | - if (!$this->controller || Str::contains('\\', $this->controller)) |
|
| 155 | - $this->controller = 'Main'; |
|
| 156 | + if (!$this->controller || Str::contains('\\', $this->controller)) { |
|
| 157 | + $this->controller = 'Main'; |
|
| 158 | + } |
|
| 156 | 159 | |
| 157 | 160 | // find callback injection in routing configs (calculated in App::run()) |
| 158 | 161 | if (Any::isArray($routing) && isset($routing['Callback'], $routing['Callback'][env_name])) { |
@@ -170,8 +173,9 @@ discard block |
||
| 170 | 173 | /** @var array $routing */ |
| 171 | 174 | $routing = App::$Properties->getAll('Routing'); |
| 172 | 175 | |
| 173 | - if (!Any::isArray($routing) || !isset($routing['Redirect']) || !Any::isArray($routing['Redirect'])) |
|
| 174 | - return; |
|
| 176 | + if (!Any::isArray($routing) || !isset($routing['Redirect']) || !Any::isArray($routing['Redirect'])) { |
|
| 177 | + return; |
|
| 178 | + } |
|
| 175 | 179 | |
| 176 | 180 | // check if source uri is key in redirect target map |
| 177 | 181 | if (array_key_exists($pathway, $routing['Redirect'])) { |
@@ -230,8 +234,9 @@ discard block |
||
| 230 | 234 | */ |
| 231 | 235 | private function findDynamicCallbacks(array $map = null, ?string $controller = null) |
| 232 | 236 | { |
| 233 | - if ($map === null) |
|
| 234 | - return; |
|
| 237 | + if ($map === null) { |
|
| 238 | + return; |
|
| 239 | + } |
|
| 235 | 240 | |
| 236 | 241 | // try to find global callback for this controller slug |
| 237 | 242 | if (array_key_exists($controller, $map)) { |
@@ -248,8 +253,9 @@ discard block |
||
| 248 | 253 | private function loadTrustedProxies() |
| 249 | 254 | { |
| 250 | 255 | $proxies = App::$Properties->get('trustedProxy'); |
| 251 | - if ($proxies === null || Str::likeEmpty($proxies)) |
|
| 252 | - return; |
|
| 256 | + if ($proxies === null || Str::likeEmpty($proxies)) { |
|
| 257 | + return; |
|
| 258 | + } |
|
| 253 | 259 | |
| 254 | 260 | $pList = explode(',', $proxies); |
| 255 | 261 | $resultList = []; |
@@ -265,8 +271,9 @@ discard block |
||
| 265 | 271 | */ |
| 266 | 272 | private function setPathdata(?array $pathArray = null) |
| 267 | 273 | { |
| 268 | - if (!Any::isArray($pathArray) || count($pathArray) < 1) |
|
| 269 | - return; |
|
| 274 | + if (!Any::isArray($pathArray) || count($pathArray) < 1) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 270 | 277 | |
| 271 | 278 | // check if array length is more then 4 basic elements and slice it recursive |
| 272 | 279 | if (count($pathArray) > 4) { |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | public function getPathInfo() |
| 296 | 303 | { |
| 297 | 304 | $route = $this->languageInPath ? Str::sub(parent::getPathInfo(), Str::length($this->language) + 1) : parent::getPathInfo(); |
| 298 | - if (!Str::startsWith('/', $route)) |
|
| 299 | - $route = '/' . $route; |
|
| 305 | + if (!Str::startsWith('/', $route)) { |
|
| 306 | + $route = '/' . $route; |
|
| 307 | + } |
|
| 300 | 308 | return $route; |
| 301 | 309 | } |
| 302 | 310 | |
@@ -439,8 +447,9 @@ discard block |
||
| 439 | 447 | public function getPathWithoutControllerAction(): ?string |
| 440 | 448 | { |
| 441 | 449 | $path = trim($this->getPathInfo(), '/'); |
| 442 | - if ($this->aliasPathTarget !== null) |
|
| 443 | - $path = trim($this->aliasPathTarget, '/'); |
|
| 450 | + if ($this->aliasPathTarget !== null) { |
|
| 451 | + $path = trim($this->aliasPathTarget, '/'); |
|
| 452 | + } |
|
| 444 | 453 | |
| 445 | 454 | $pathArray = explode('/', $path); |
| 446 | 455 | if ($pathArray[0] === Str::lowerCase($this->getController())) { |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use Ffcms\Core\Exception\SyntaxException; |
| 9 | 9 | use Ffcms\Core\Helper\ModelFilters; |
| 10 | 10 | use Ffcms\Core\Helper\Type\Any; |
| 11 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 12 | 11 | use Ffcms\Core\Helper\Type\Str; |
| 13 | 12 | |
| 14 | 13 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } elseif (method_exists($class, $obj)) { // maybe its a function? |
| 138 | 138 | $class = $class::$obj; // call function |
| 139 | 139 | } else { |
| 140 | - throw new SyntaxException('Filter callback execution failed: ' . $filterName); |
|
| 140 | + throw new SyntaxException('Filter callback execution failed: '.$filterName); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if (method_exists($class, $method)) { |
| 147 | 147 | $check = @$class::$method($fieldValue, $filterArgs); |
| 148 | 148 | } else { |
| 149 | - throw new SyntaxException('Filter callback execution failed: ' . $filterName); |
|
| 149 | + throw new SyntaxException('Filter callback execution failed: '.$filterName); |
|
| 150 | 150 | } |
| 151 | 151 | } elseif (method_exists('Ffcms\Core\Helper\ModelFilters', $filterName)) { // only full namespace\class path based :( |
| 152 | 152 | if ($filterArgs != null) { |
@@ -155,14 +155,14 @@ discard block |
||
| 155 | 155 | $check = ModelFilters::$filterName($fieldValue); |
| 156 | 156 | } |
| 157 | 157 | } else { |
| 158 | - throw new SyntaxException('Filter "' . $filterName . '" is not exist'); |
|
| 158 | + throw new SyntaxException('Filter "'.$filterName.'" is not exist'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // if one from all validation tests is fail - mark as incorrect attribute |
| 162 | 162 | if ($check !== true) { |
| 163 | 163 | $this->_badAttr[] = $propertyName; |
| 164 | 164 | if (App::$Debug) |
| 165 | - App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
| 165 | + App::$Debug->addMessage('Validation failed. Property: '.$propertyName.', filter: '.$filterName, 'warning'); |
|
| 166 | 166 | } else { |
| 167 | 167 | $field_set_name = $propertyName; |
| 168 | 168 | // prevent array-type setting |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | // if request is submited for this model - try to validate input data |
| 42 | 42 | if ($this->send()) { |
| 43 | 43 | // token is wrong - update bool state |
| 44 | - if ($currentToken !== $this->getRequest('_csrf_token')) |
|
| 45 | - $this->_tokenOk = false; |
|
| 44 | + if ($currentToken !== $this->getRequest('_csrf_token')) { |
|
| 45 | + $this->_tokenOk = false; |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | // set token data to display |
| 48 | 49 | $this->_csrf_token = $newToken; |
@@ -58,21 +59,24 @@ discard block |
||
| 58 | 59 | public function runValidate(array $rules = null) |
| 59 | 60 | { |
| 60 | 61 | // skip validation on empty rules |
| 61 | - if ($rules === null) |
|
| 62 | - return true; |
|
| 62 | + if ($rules === null) { |
|
| 63 | + return true; |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | $success = true; |
| 65 | 67 | // list each rule as single one |
| 66 | 68 | foreach ($rules as $rule) { |
| 67 | 69 | // 0 = field (property) name, 1 = filter name, 2 = filter value |
| 68 | - if ($rule[0] === null || $rule[1] === null) |
|
| 69 | - continue; |
|
| 70 | + if ($rule[0] === null || $rule[1] === null) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | $propertyName = $rule[0]; |
| 72 | 75 | $validationRule = $rule[1]; |
| 73 | 76 | $validationValue = null; |
| 74 | - if (isset($rule[2])) |
|
| 75 | - $validationValue = $rule[2]; |
|
| 77 | + if (isset($rule[2])) { |
|
| 78 | + $validationValue = $rule[2]; |
|
| 79 | + } |
|
| 76 | 80 | |
| 77 | 81 | // check if target field defined as array and make recursive validation |
| 78 | 82 | if (Any::isArray($propertyName)) { |
@@ -160,8 +164,9 @@ discard block |
||
| 160 | 164 | // if one from all validation tests is fail - mark as incorrect attribute |
| 161 | 165 | if ($check !== true) { |
| 162 | 166 | $this->_badAttr[] = $propertyName; |
| 163 | - if (App::$Debug) |
|
| 164 | - App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
| 167 | + if (App::$Debug) { |
|
| 168 | + App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning'); |
|
| 169 | + } |
|
| 165 | 170 | } else { |
| 166 | 171 | $field_set_name = $propertyName; |
| 167 | 172 | // prevent array-type setting |
@@ -172,8 +177,9 @@ discard block |
||
| 172 | 177 | if ($propertyName !== $field_set_name) { // array-based property |
| 173 | 178 | $dot_path = trim(strstr($propertyName, '.'), '.'); |
| 174 | 179 | // prevent throws any exceptions for null and false objects |
| 175 | - if (!Any::isArray($this->{$field_set_name})) |
|
| 176 | - $this->{$field_set_name} = []; |
|
| 180 | + if (!Any::isArray($this->{$field_set_name})) { |
|
| 181 | + $this->{$field_set_name} = []; |
|
| 182 | + } |
|
| 177 | 183 | |
| 178 | 184 | // use dot-data provider to compile output array |
| 179 | 185 | $dotData = new DotData($this->{$field_set_name}); |
@@ -203,14 +209,16 @@ discard block |
||
| 203 | 209 | $sources = $this->sources(); |
| 204 | 210 | $types = $this->types(); |
| 205 | 211 | // validate sources for current field |
| 206 | - if (array_key_exists($propertyName, $sources)) |
|
| 207 | - $inputType = Str::lowerCase($sources[$propertyName]); |
|
| 212 | + if (array_key_exists($propertyName, $sources)) { |
|
| 213 | + $inputType = Str::lowerCase($sources[$propertyName]); |
|
| 214 | + } |
|
| 208 | 215 | |
| 209 | 216 | |
| 210 | 217 | // check if field is array-nested element by dots and use first element as general |
| 211 | 218 | $filterField = $propertyName; |
| 212 | - if (array_key_exists($filterField, $types)) |
|
| 213 | - $filterType = Str::lowerCase($types[$filterField]); |
|
| 219 | + if (array_key_exists($filterField, $types)) { |
|
| 220 | + $filterType = Str::lowerCase($types[$filterField]); |
|
| 221 | + } |
|
| 214 | 222 | |
| 215 | 223 | // get clear field value |
| 216 | 224 | $propertyValue = $this->getRequest($propertyName, $inputType); |
@@ -312,8 +320,9 @@ discard block |
||
| 312 | 320 | */ |
| 313 | 321 | public function getRequest($param, $method = null) |
| 314 | 322 | { |
| 315 | - if ($method === null) |
|
| 316 | - $method = $this->_sendMethod; |
|
| 323 | + if ($method === null) { |
|
| 324 | + $method = $this->_sendMethod; |
|
| 325 | + } |
|
| 317 | 326 | |
| 318 | 327 | $method = Str::lowerCase($method); |
| 319 | 328 | // get root request as array or string |
@@ -337,8 +346,9 @@ discard block |
||
| 337 | 346 | if (Str::contains('.', $param)) { |
| 338 | 347 | $response = $request; |
| 339 | 348 | foreach (explode('.', $param) as $path) { |
| 340 | - if ($response !== null && !array_key_exists($path, $response)) |
|
| 341 | - return null; |
|
| 349 | + if ($response !== null && !array_key_exists($path, $response)) { |
|
| 350 | + return null; |
|
| 351 | + } |
|
| 342 | 352 | // find deep array nesting offset |
| 343 | 353 | $response = $response[$path]; |
| 344 | 354 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | { |
| 18 | 18 | $hash = null; |
| 19 | 19 | foreach ($this as $property => $value) { |
| 20 | - $hash = md5($hash . $property . '=' . $value); |
|
| 20 | + $hash = md5($hash.$property.'='.$value); |
|
| 21 | 21 | } |
| 22 | 22 | return $hash; |
| 23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public static function to($controller_action, $id = null, $add = null, array $params = null, $encode = true) |
| 26 | 26 | { |
| 27 | 27 | $pathway = self::buildPathway([$controller_action, $id, $add, $params], $encode); |
| 28 | - return App::$Alias->baseUrl . '/' . $pathway; |
|
| 28 | + return App::$Alias->baseUrl.'/'.$pathway; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $controller = Str::lastIn($controller, '\\', true); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $response = $controller . '/' . $action; |
|
| 64 | + $response = $controller.'/'.$action; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // check if controller and action is defined |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // id is defined? |
| 73 | 73 | if (isset($to[1]) && !Str::likeEmpty($to[1])) { |
| 74 | - $response .= '/' . self::safeUri($to[1], $encode); |
|
| 74 | + $response .= '/'.self::safeUri($to[1], $encode); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // add param is defined? |
| 78 | 78 | if (isset($to[2]) && !Str::likeEmpty($to[2])) { |
| 79 | - $response .= '/' . self::safeUri($to[2], $encode); |
|
| 79 | + $response .= '/'.self::safeUri($to[2], $encode); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // try to find static alias |
| 83 | - if (isset($routing['Alias'][env_name]) && Arr::in('/' . $response, $routing['Alias'][env_name])) { |
|
| 84 | - $pathAlias = array_search('/' . $response, $routing['Alias'][env_name]); |
|
| 83 | + if (isset($routing['Alias'][env_name]) && Arr::in('/'.$response, $routing['Alias'][env_name])) { |
|
| 84 | + $pathAlias = array_search('/'.$response, $routing['Alias'][env_name]); |
|
| 85 | 85 | if ($pathAlias !== false) { |
| 86 | 86 | $response = Str::lowerCase(trim($pathAlias, '/')); |
| 87 | 87 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | $queryString = http_build_query($to[3]); |
| 99 | 99 | if (Str::length($queryString) > 0) { |
| 100 | - $response .= '?' . http_build_query($to[3]); |
|
| 100 | + $response .= '?'.http_build_query($to[3]); |
|
| 101 | 101 | } |
| 102 | 102 | if ($anchor !== false) { |
| 103 | 103 | $response .= $anchor; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public static function buildPathwayFromRequest() |
| 120 | 120 | { |
| 121 | 121 | return self::buildPathway([ |
| 122 | - Str::lowerCase(App::$Request->getController()) . '/' . Str::lowerCase(App::$Request->getAction()), |
|
| 122 | + Str::lowerCase(App::$Request->getController()).'/'.Str::lowerCase(App::$Request->getAction()), |
|
| 123 | 123 | App::$Request->getID(), |
| 124 | 124 | App::$Request->getAdd(), |
| 125 | 125 | App::$Request->query->all() |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | $to = [$to]; |
| 141 | 141 | |
| 142 | 142 | // call Url::to(args) |
| 143 | - $callbackTo = call_user_func_array([__NAMESPACE__ . '\Url', 'to'], $to); |
|
| 143 | + $callbackTo = call_user_func_array([__NAMESPACE__.'\Url', 'to'], $to); |
|
| 144 | 144 | |
| 145 | - return '<a href="' . $callbackTo . '"' . $compile_property . '>' . $name . '</a>'; |
|
| 145 | + return '<a href="'.$callbackTo.'"'.$compile_property.'>'.$name.'</a>'; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -155,19 +155,19 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | /** @var array $configs */ |
| 157 | 157 | $configs = \App::$Properties->getAll('default'); |
| 158 | - $httpHost = $configs['baseProto'] . '://' . $configs['baseDomain']; |
|
| 158 | + $httpHost = $configs['baseProto'].'://'.$configs['baseDomain']; |
|
| 159 | 159 | if ($configs['basePath'] !== '/') { |
| 160 | - $httpHost .= $configs['basePath'] . '/'; |
|
| 160 | + $httpHost .= $configs['basePath'].'/'; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // check if is this is URI not URL |
| 164 | 164 | if (!Str::startsWith($httpHost, $uri)) { |
| 165 | 165 | // check if lang is defined in URI or define it |
| 166 | 166 | if ($lang !== null && $configs['multiLanguage'] && !Str::startsWith($lang, $uri)) { |
| 167 | - $uri = $lang . '/' . ltrim($uri, '/'); |
|
| 167 | + $uri = $lang.'/'.ltrim($uri, '/'); |
|
| 168 | 168 | } |
| 169 | 169 | // add basic httpHost data |
| 170 | - $uri = rtrim($httpHost, '/') . '/' . ltrim($uri, '/'); |
|
| 170 | + $uri = rtrim($httpHost, '/').'/'.ltrim($uri, '/'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $uri; |
@@ -136,8 +136,9 @@ |
||
| 136 | 136 | public static function link($to, $name, array $property = null) |
| 137 | 137 | { |
| 138 | 138 | $compile_property = self::applyProperty($property); |
| 139 | - if (!Any::isArray($to)) |
|
| 140 | - $to = [$to]; |
|
| 139 | + if (!Any::isArray($to)) { |
|
| 140 | + $to = [$to]; |
|
| 141 | + } |
|
| 141 | 142 | |
| 142 | 143 | // call Url::to(args) |
| 143 | 144 | $callbackTo = call_user_func_array([__NAMESPACE__ . '\Url', 'to'], $to); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | $breakerPos = mb_strpos($text, '<br', null, 'UTF-8'); |
| 36 | 36 | } else { |
| 37 | 37 | // add length('</p>') |
| 38 | - $breakerPos+= 4; |
|
| 38 | + $breakerPos += 4; |
|
| 39 | 39 | } |
| 40 | 40 | // cut text from position caret before </p> (+4 symbols to save item as valid) |
| 41 | 41 | if ($breakerPos !== false) { |
@@ -21,13 +21,15 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function parseUserNick($userId = null, $onEmpty = 'guest'): ?string |
| 23 | 23 | { |
| 24 | - if (!Any::isInt($userId)) |
|
| 25 | - return \App::$Security->strip_tags($onEmpty); |
|
| 24 | + if (!Any::isInt($userId)) { |
|
| 25 | + return \App::$Security->strip_tags($onEmpty); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // try to find user active record as object |
| 28 | 29 | $identity = App::$User->identity($userId); |
| 29 | - if (!$identity) |
|
| 30 | - return \App::$Security->strip_tags($onEmpty); |
|
| 30 | + if (!$identity) { |
|
| 31 | + return \App::$Security->strip_tags($onEmpty); |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | // return user nickname from profile |
| 33 | 35 | return $identity->profile->getNickname(); |
@@ -44,8 +46,9 @@ discard block |
||
| 44 | 46 | { |
| 45 | 47 | $nick = self::parseUserNick($userId, $onEmpty); |
| 46 | 48 | // new name is not found, lets return default |
| 47 | - if ($nick === $onEmpty || (int)$userId < 1) |
|
| 48 | - return $nick; |
|
| 49 | + if ($nick === $onEmpty || (int)$userId < 1) { |
|
| 50 | + return $nick; |
|
| 51 | + } |
|
| 49 | 52 | |
| 50 | 53 | return Url::link([$controllerAction, (int)$userId], $nick); |
| 51 | 54 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $pattern = rtrim($path, '/') . '/*'; |
|
| 94 | + $pattern = rtrim($path, '/').'/*'; |
|
| 95 | 95 | $entry = glob($pattern, $mod); |
| 96 | 96 | |
| 97 | 97 | if ($returnRelative === true) { |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | array_pop($separatedPath); |
| 123 | 123 | $clearPath = implode(DIRECTORY_SEPARATOR, $separatedPath); |
| 124 | 124 | |
| 125 | - @rename($path, $clearPath . DIRECTORY_SEPARATOR . $newDirName); |
|
| 125 | + @rename($path, $clearPath.DIRECTORY_SEPARATOR.$newDirName); |
|
| 126 | 126 | |
| 127 | 127 | return true; |
| 128 | 128 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | { |
| 56 | 56 | $path = self::diskPath($path); |
| 57 | 57 | if (!Str::startsWith(root, $path)) { |
| 58 | - $path = root . DIRECTORY_SEPARATOR . ltrim($path, '\\/'); |
|
| 58 | + $path = root.DIRECTORY_SEPARATOR.ltrim($path, '\\/'); |
|
| 59 | 59 | } |
| 60 | 60 | return $path; |
| 61 | 61 | } |