@@ -36,8 +36,8 @@ |
||
| 36 | 36 | $dto[$property->getName()] = $property->getValue($this); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | - } catch (\Exception $e) { |
|
| 40 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 39 | + }catch (\Exception $e) { |
|
| 40 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 41 | 41 | } |
| 42 | 42 | return $dto; |
| 43 | 43 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | { |
| 63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
| 64 | 64 | return Order::ASC; |
| 65 | - } else { |
|
| 65 | + }else { |
|
| 66 | 66 | return Order::DESC; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $namespace = explode('\\', $this->getModelTableMap()); |
| 28 | 28 | $module = strtolower($namespace[0]); |
| 29 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
| 29 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
| 30 | 30 | if (NULL === $secret) { |
| 31 | 31 | $secret = Config::getInstance()->get("api.secret"); |
| 32 | 32 | } |
| 33 | 33 | if (NULL === $secret) { |
| 34 | 34 | $auth = TRUE; |
| 35 | - } else { |
|
| 35 | + }else { |
|
| 36 | 36 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
| 37 | 37 | if (array_key_exists('API_TOKEN', $this->query)) { |
| 38 | 38 | $token = $this->query['API_TOKEN']; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @param ModelCriteria $query |
| 182 | 182 | */ |
| 183 | - private function addOrders(ModelCriteria &$query) |
|
| 183 | + private function addOrders(ModelCriteria & $query) |
|
| 184 | 184 | { |
| 185 | 185 | $orderAdded = FALSE; |
| 186 | 186 | $tableMap = $this->getTableMap(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $orderAdded = TRUE; |
| 190 | 190 | if ($direction === Order::ASC) { |
| 191 | 191 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 192 | - } else { |
|
| 192 | + }else { |
|
| 193 | 193 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 194 | 194 | } |
| 195 | 195 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | if (count($pks) == 1) { |
| 210 | 210 | $pks = array_keys($pks); |
| 211 | 211 | $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD; |
| 212 | - } else { |
|
| 212 | + }else { |
|
| 213 | 213 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | if (null !== $column) { |
| 233 | 233 | $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD; |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | $this->addClassListName($tableMap); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @param ModelCriteria $query |
| 245 | 245 | */ |
| 246 | - private function addExtraColumns(ModelCriteria &$query) |
|
| 246 | + private function addExtraColumns(ModelCriteria & $query) |
|
| 247 | 247 | { |
| 248 | 248 | if (self::API_ACTION_LIST === $this->action) { |
| 249 | 249 | $this->addDefaultListField(); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @param ModelCriteria $query |
| 263 | 263 | */ |
| 264 | - protected function joinTables(ModelCriteria &$query) |
|
| 264 | + protected function joinTables(ModelCriteria & $query) |
|
| 265 | 265 | { |
| 266 | 266 | //TODO for specific implementations |
| 267 | 267 | } |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @param ModelCriteria $query |
| 285 | 285 | */ |
| 286 | - private function addFilters(ModelCriteria &$query) |
|
| 286 | + private function addFilters(ModelCriteria & $query) |
|
| 287 | 287 | { |
| 288 | 288 | if (count($this->query) > 0) { |
| 289 | 289 | $tableMap = $this->getTableMap(); |
| 290 | 290 | foreach ($this->query as $field => $value) { |
| 291 | 291 | if (self::API_COMBO_FIELD === $field) { |
| 292 | 292 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
| 293 | - } else { |
|
| 293 | + }else { |
|
| 294 | 294 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | /** |
| 301 | 301 | * @param ModelCriteria $query |
| 302 | 302 | */ |
| 303 | - private function checkReturnFields(ModelCriteria &$query) |
|
| 303 | + private function checkReturnFields(ModelCriteria & $query) |
|
| 304 | 304 | { |
| 305 | 305 | $returnFields = $this->getRequest()->getQuery('__fields'); |
| 306 | 306 | if (null !== $returnFields) { |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | list($page, $limit) = $this->extractPagination(); |
| 337 | 337 | if ($limit == -1) { |
| 338 | 338 | $this->list = $query->find($this->con); |
| 339 | - } else { |
|
| 339 | + }else { |
|
| 340 | 340 | $this->list = $query->paginate($page, $limit, $this->con); |
| 341 | 341 | } |
| 342 | - } catch (\Exception $e) { |
|
| 342 | + }catch (\Exception $e) { |
|
| 343 | 343 | Logger::log($e->getMessage(), LOG_ERR); |
| 344 | 344 | } |
| 345 | 345 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $this->joinTables($query); |
| 357 | 357 | $this->addExtraColumns($query); |
| 358 | 358 | $this->model = $query->findPk($pk); |
| 359 | - } catch (\Exception $e) { |
|
| 359 | + }catch (\Exception $e) { |
|
| 360 | 360 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | $saved = TRUE; |
| 448 | 448 | $model = $this->model->toArray(); |
| 449 | 449 | } |
| 450 | - } catch (\Exception $e) { |
|
| 451 | - $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage(); |
|
| 450 | + }catch (\Exception $e) { |
|
| 451 | + $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage(); |
|
| 452 | 452 | Logger::log($e->getMessage(), LOG_ERR); |
| 453 | 453 | } |
| 454 | 454 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | $this->model->delete($this->con); |
| 479 | 479 | $deleted = TRUE; |
| 480 | 480 | } |
| 481 | - } catch (\Exception $e) { |
|
| 481 | + }catch (\Exception $e) { |
|
| 482 | 482 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
| 483 | 483 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 484 | 484 | } |
@@ -513,14 +513,14 @@ discard block |
||
| 513 | 513 | $updated = TRUE; |
| 514 | 514 | $status = 200; |
| 515 | 515 | $model = $this->model->toArray(); |
| 516 | - } else { |
|
| 516 | + }else { |
|
| 517 | 517 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 518 | 518 | } |
| 519 | - } catch (\Exception $e) { |
|
| 519 | + }catch (\Exception $e) { |
|
| 520 | 520 | $model = $e->getMessage(); |
| 521 | 521 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 522 | 522 | } |
| 523 | - } else { |
|
| 523 | + }else { |
|
| 524 | 524 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | */ |
| 533 | 533 | private function extractQuery() |
| 534 | 534 | { |
| 535 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
| 535 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
| 536 | 536 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 537 | 537 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
| 538 | 538 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | if (null !== $this->con && $this->con->inTransaction()) { |
| 577 | 577 | if ($status === 200) { |
| 578 | 578 | $this->con->commit(); |
| 579 | - } else { |
|
| 579 | + }else { |
|
| 580 | 580 | $this->con->rollBack(); |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -628,8 +628,8 @@ discard block |
||
| 628 | 628 | "domain" => $this->getDomain(), |
| 629 | 629 | "listLabel" => self::API_LIST_NAME_FIELD, |
| 630 | 630 | 'modelId' => self::API_MODEL_KEY_FIELD, |
| 631 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
| 632 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 631 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
| 632 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
| 633 | 633 | ), [], ''); |
| 634 | 634 | } |
| 635 | 635 | |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | $total = $this->list->getNbResults(); |
| 669 | 669 | $pages = $this->list->getLastPage(); |
| 670 | 670 | } |
| 671 | - } catch (\Exception $e) { |
|
| 671 | + }catch (\Exception $e) { |
|
| 672 | 672 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 673 | 673 | } |
| 674 | 674 | |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | $return = array(); |
| 688 | 688 | if (NULL === $model && method_exists($model, 'toArray')) { |
| 689 | 689 | $code = 404; |
| 690 | - } else { |
|
| 690 | + }else { |
|
| 691 | 691 | $return = $model->toArray(); |
| 692 | 692 | } |
| 693 | 693 | |
@@ -702,10 +702,10 @@ discard block |
||
| 702 | 702 | $pks = ''; |
| 703 | 703 | $sep = ''; |
| 704 | 704 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
| 705 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
| 705 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
| 706 | 706 | $sep = ', "|", '; |
| 707 | 707 | } |
| 708 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD; |
|
| 708 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD; |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
@@ -603,6 +603,9 @@ discard block |
||
| 603 | 603 | $this->con->useDebug($this->debug); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | + /** |
|
| 607 | + * @return string |
|
| 608 | + */ |
|
| 606 | 609 | private function getApi() |
| 607 | 610 | { |
| 608 | 611 | $model = explode("\\", $this->getModelNamespace()); |
@@ -610,6 +613,9 @@ discard block |
||
| 610 | 613 | return $model[count($model) - 1]; |
| 611 | 614 | } |
| 612 | 615 | |
| 616 | + /** |
|
| 617 | + * @return string |
|
| 618 | + */ |
|
| 613 | 619 | public function getDomain() |
| 614 | 620 | { |
| 615 | 621 | $model = explode("\\", $this->getModelNamespace()); |
@@ -14,12 +14,10 @@ |
||
| 14 | 14 | use PSFS\base\Request; |
| 15 | 15 | use PSFS\base\Router; |
| 16 | 16 | use PSFS\base\Singleton; |
| 17 | -use PSFS\base\Template; |
|
| 18 | 17 | use PSFS\base\types\helpers\ApiFormHelper; |
| 19 | 18 | use PSFS\base\types\helpers\ApiHelper; |
| 20 | 19 | use PSFS\base\types\traits\JsonTrait; |
| 21 | 20 | use PSFS\base\types\traits\RouteTrait; |
| 22 | -use PSFS\base\types\traits\SingletonTrait; |
|
| 23 | 21 | |
| 24 | 22 | /** |
| 25 | 23 | * Class Api |
@@ -30,16 +30,16 @@ |
||
| 30 | 30 | $scripts = $this->getNode("scripts"); |
| 31 | 31 | |
| 32 | 32 | //Creamos el parser |
| 33 | - $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\'' . $this->type . '\')') |
|
| 33 | + $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\''.$this->type.'\')') |
|
| 34 | 34 | ->raw(";\n"); |
| 35 | 35 | |
| 36 | 36 | //Asociamos el hash |
| 37 | - $compiler->write('$parser->setHash(\'' . $this->hash . '\')') |
|
| 37 | + $compiler->write('$parser->setHash(\''.$this->hash.'\')') |
|
| 38 | 38 | ->raw(";\n"); |
| 39 | 39 | |
| 40 | 40 | //Asociamos los ficheros |
| 41 | 41 | foreach ($scripts->getAttribute("value") as $value) { |
| 42 | - $compiler->write('$parser->addFile(\'' . $value . '\')')->raw(";\n"); |
|
| 42 | + $compiler->write('$parser->addFile(\''.$value.'\')')->raw(";\n"); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | //Procesamos los ficheros |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | $tmp = array(); |
| 140 | 140 | if (NULL === $node) { |
| 141 | 141 | $node = $value; |
| 142 | - } else { |
|
| 142 | + }else { |
|
| 143 | 143 | $tmp = $this->getTmpAttribute($node); |
| 144 | 144 | } |
| 145 | 145 | $tmp[] = $value->getAttribute("value"); |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $saved = true; |
| 124 | 124 | try { |
| 125 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 126 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 125 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 126 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 127 | 127 | $admins[$user['username']]['profile'] = $user['profile']; |
| 128 | 128 | |
| 129 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 130 | - } catch(\Exception $e) { |
|
| 129 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 130 | + }catch (\Exception $e) { |
|
| 131 | 131 | Logger::log($e->getMessage(), LOG_ERR); |
| 132 | 132 | $saved = false; |
| 133 | 133 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function getAdmins() |
| 166 | 166 | { |
| 167 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
| 167 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | if (!empty($user) && !empty($admins[$user])) { |
| 193 | 193 | $auth = $admins[$user]['hash']; |
| 194 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 194 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 195 | 195 | if ($this->authorized) { |
| 196 | 196 | $this->admin = array( |
| 197 | 197 | 'alias' => $user, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | /** |
| 117 | 117 | * Add request param |
| 118 | 118 | * |
| 119 | - * @param $key |
|
| 119 | + * @param integer $key |
|
| 120 | 120 | * @param null $value |
| 121 | 121 | * |
| 122 | 122 | * @return \PSFS\base\Service |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * @param $header |
|
| 157 | - * @param null $content |
|
| 156 | + * @param string $header |
|
| 157 | + * @param string $content |
|
| 158 | 158 | * |
| 159 | 159 | * @return $this |
| 160 | 160 | */ |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | protected $cache; |
| 55 | 55 | |
| 56 | 56 | private function closeConnection() { |
| 57 | - if(null !== $this->con) { |
|
| 57 | + if (null !== $this->con) { |
|
| 58 | 58 | curl_close($this->con); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $this->url = NULL; |
| 221 | 221 | $this->params = array(); |
| 222 | 222 | $this->headers = array(); |
| 223 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
| 223 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
| 224 | 224 | $this->closeConnection(); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if (!Config::getInstance()->checkTryToSaveConfig() |
| 30 | 30 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
| 31 | 31 | ) { |
| 32 | - if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
| 32 | + if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
| 33 | 33 | throw new AdminCredentialsException(); |
| 34 | 34 | } |
| 35 | 35 | if (!Security::getInstance()->checkAdmin()) { |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | $token = ''; |
| 50 | 50 | $ct = strlen($ts); |
| 51 | 51 | for ($i = 0; $i < $ct; $i++) { |
| 52 | - $token = substr($hash, $i, 1) . |
|
| 53 | - substr($ts, $i, 1) . |
|
| 52 | + $token = substr($hash, $i, 1). |
|
| 53 | + substr($ts, $i, 1). |
|
| 54 | 54 | $token; |
| 55 | 55 | } |
| 56 | 56 | return $token; |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | $charsLength = strlen(self::RAND_SEP) - 1; |
| 69 | 69 | $tsLength = strlen($ts); |
| 70 | 70 | $i = 0; |
| 71 | - $ct = ceil($hashRest / 4); |
|
| 72 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
| 73 | - while(false !== $part) { |
|
| 74 | - $mixedToken .= $part . |
|
| 75 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
| 71 | + $ct = ceil($hashRest/4); |
|
| 72 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
| 73 | + while (false !== $part) { |
|
| 74 | + $mixedToken .= $part. |
|
| 75 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
| 76 | 76 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
| 77 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
| 77 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
| 78 | 78 | $i++; |
| 79 | 79 | } |
| 80 | - return $mixedToken . $token; |
|
| 80 | + return $mixedToken.$token; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | private static function getTs($isOdd = null) { |
| 88 | 88 | $ts = time(); |
| 89 | - $tsIsOdd = (bool)((int)substr($ts, -1) % 2); |
|
| 90 | - if(false === $isOdd && !$tsIsOdd) { |
|
| 89 | + $tsIsOdd = (bool)((int)substr($ts, -1)%2); |
|
| 90 | + if (false === $isOdd && !$tsIsOdd) { |
|
| 91 | 91 | $ts--; |
| 92 | - } elseif(true === $isOdd && !$tsIsOdd) { |
|
| 92 | + } elseif (true === $isOdd && !$tsIsOdd) { |
|
| 93 | 93 | $ts--; |
| 94 | 94 | } |
| 95 | 95 | return $ts; |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | $partToken = ''; |
| 122 | 122 | $ts = ''; |
| 123 | 123 | $part = strrev($part); |
| 124 | - for($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
| 125 | - if($i % 2 == 0) { |
|
| 124 | + for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
| 125 | + if ($i%2 == 0) { |
|
| 126 | 126 | $ts .= substr($part, $i, 1); |
| 127 | - } else { |
|
| 127 | + }else { |
|
| 128 | 128 | $partToken .= substr($part, $i, 1); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | private static function parseTokenParts(array $parts) { |
| 140 | 140 | $token = ''; |
| 141 | 141 | list($partToken, $ts) = self::extractTs(array_pop($parts)); |
| 142 | - if($ts > 0) { |
|
| 143 | - foreach($parts as $part) { |
|
| 142 | + if ($ts > 0) { |
|
| 143 | + foreach ($parts as $part) { |
|
| 144 | 144 | $token .= $part; |
| 145 | 145 | } |
| 146 | - $token = $partToken . $token; |
|
| 146 | + $token = $partToken.$token; |
|
| 147 | 147 | } |
| 148 | 148 | return [$token, $ts]; |
| 149 | 149 | } |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @return array |
| 172 | 172 | */ |
| 173 | 173 | private static function extractTokenParts($token) { |
| 174 | - for($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
| 175 | - $token = str_replace(substr(self::RAND_SEP,$i,1), "|", $token); |
|
| 174 | + for ($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
| 175 | + $token = str_replace(substr(self::RAND_SEP, $i, 1), "|", $token); |
|
| 176 | 176 | } |
| 177 | 177 | return array_unique(explode('||', $token)); |
| 178 | 178 | } |