@@ -83,13 +83,11 @@ discard block |
||
| 83 | 83 | // get params |
| 84 | 84 | $params = $this->getMethodParams($methodOptions->getParams()); |
| 85 | 85 | $this->sourceCode .= PhpInterface::TAB_PSR4 . $methodOptions->getModifier() . PhpInterface::SPACE . |
| 86 | - (($methodOptions->isStatic() !== false) ? PhpInterface::PHP_STATIC . PhpInterface::SPACE : |
|
| 87 | - '') . |
|
| 86 | + (($methodOptions->isStatic() !== false) ? PhpInterface::PHP_STATIC . PhpInterface::SPACE : '') . |
|
| 88 | 87 | PhpInterface::PHP_FUNCTION . PhpInterface::SPACE . |
| 89 | 88 | $methodOptions->getName() |
| 90 | 89 | . PhpInterface::OPEN_PARENTHESES . $params . PhpInterface::CLOSE_PARENTHESES . |
| 91 | - ((empty($methodOptions->getReturnType())) ? '' : |
|
| 92 | - PhpInterface::COLON . PhpInterface::SPACE . $methodOptions->getReturnType()) . |
|
| 90 | + ((empty($methodOptions->getReturnType())) ? '' : PhpInterface::COLON . PhpInterface::SPACE . $methodOptions->getReturnType()) . |
|
| 93 | 91 | PhpInterface::SPACE . PHP_EOL . PhpInterface::TAB_PSR4 |
| 94 | 92 | . PhpInterface::OPEN_BRACE . PHP_EOL; |
| 95 | 93 | } |
@@ -103,8 +101,7 @@ discard block |
||
| 103 | 101 | protected function setMethodReturn(string $value, $isString = false): void |
| 104 | 102 | { |
| 105 | 103 | $this->setTabs(2); |
| 106 | - $this->sourceCode .= PhpInterface::PHP_RETURN . PhpInterface::SPACE . (($isString === false) ? $value : |
|
| 107 | - PhpInterface::DOUBLE_QUOTES . $value . PhpInterface::DOUBLE_QUOTES) . PhpInterface::SEMICOLON . PHP_EOL; |
|
| 104 | + $this->sourceCode .= PhpInterface::PHP_RETURN . PhpInterface::SPACE . (($isString === false) ? $value : PhpInterface::DOUBLE_QUOTES . $value . PhpInterface::DOUBLE_QUOTES) . PhpInterface::SEMICOLON . PHP_EOL; |
|
| 108 | 105 | } |
| 109 | 106 | |
| 110 | 107 | /** |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | public function create() |
| 45 | 45 | { |
| 46 | 46 | $migrationName = ModelsInterface::MIGRATION_CREATE . PhpInterface::UNDERSCORE . |
| 47 | - $this->tableName . |
|
| 48 | - PhpInterface::UNDERSCORE . ModelsInterface::MIGRATION_TABLE; |
|
| 47 | + $this->tableName . |
|
| 48 | + PhpInterface::UNDERSCORE . ModelsInterface::MIGRATION_TABLE; |
|
| 49 | 49 | $attrKey = $this->generator->objectName . CustomsInterface::CUSTOM_TYPES_ATTRIBUTES; |
| 50 | 50 | |
| 51 | 51 | $isFileNonExistent = FileManager::migrationNotExists($this->generator, $migrationName); |
@@ -82,20 +82,20 @@ discard block |
||
| 82 | 82 | foreach($relations as $relationEntity) |
| 83 | 83 | { |
| 84 | 84 | $entityFile = $this->generator->formatEntitiesPath() |
| 85 | - . PhpInterface::SLASH . |
|
| 86 | - $this->generator->objectName . |
|
| 87 | - ucfirst($relationEntity) . |
|
| 88 | - PhpInterface::PHP_EXT; |
|
| 85 | + . PhpInterface::SLASH . |
|
| 86 | + $this->generator->objectName . |
|
| 87 | + ucfirst($relationEntity) . |
|
| 88 | + PhpInterface::PHP_EXT; |
|
| 89 | 89 | if(file_exists($entityFile)) |
| 90 | 90 | { |
| 91 | 91 | $this->setPivotContent($relationEntity); |
| 92 | 92 | |
| 93 | 93 | $migrationMask = date(self::PATTERN_TIME) . (self::$counter + 1); |
| 94 | 94 | $migrationName = ModelsInterface::MIGRATION_CREATE . PhpInterface::UNDERSCORE |
| 95 | - . $this->tableName |
|
| 96 | - . PhpInterface::UNDERSCORE . |
|
| 97 | - MigrationsHelper::getTableName($relationEntity) . |
|
| 98 | - PhpInterface::UNDERSCORE . ModelsInterface::MIGRATION_TABLE; |
|
| 95 | + . $this->tableName |
|
| 96 | + . PhpInterface::UNDERSCORE . |
|
| 97 | + MigrationsHelper::getTableName($relationEntity) . |
|
| 98 | + PhpInterface::UNDERSCORE . ModelsInterface::MIGRATION_TABLE; |
|
| 99 | 99 | |
| 100 | 100 | if(FileManager::migrationNotExists($this->generator, $migrationName)) |
| 101 | 101 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $isFileNonExistent = FileManager::migrationNotExists($this->generator, $migrationName); |
| 52 | 52 | $isAdding = ($this->generator->isMerge === true && empty($this->generator->diffTypes[$attrKey]) === false); |
| 53 | 53 | |
| 54 | - if($isFileNonExistent === true) |
|
| 54 | + if ($isFileNonExistent === true) |
|
| 55 | 55 | { |
| 56 | 56 | $this->setContent(); |
| 57 | 57 | } else if ($isAdding === true) { |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | $formRequestEntity = $this->getFormRequestEntity($this->generator->version, $this->className); |
| 77 | 77 | /** @var BaseFormRequest $formRequest **/ |
| 78 | 78 | $formRequest = new $formRequestEntity(); |
| 79 | - if(method_exists($formRequest, ModelsInterface::MODEL_METHOD_RELATIONS)) |
|
| 79 | + if (method_exists($formRequest, ModelsInterface::MODEL_METHOD_RELATIONS)) |
|
| 80 | 80 | { |
| 81 | 81 | $relations = $formRequest->relations(); |
| 82 | - foreach($relations as $relationEntity) |
|
| 82 | + foreach ($relations as $relationEntity) |
|
| 83 | 83 | { |
| 84 | 84 | $entityFile = $this->generator->formatEntitiesPath() |
| 85 | 85 | . PhpInterface::SLASH . |
| 86 | 86 | $this->generator->objectName . |
| 87 | 87 | ucfirst($relationEntity) . |
| 88 | 88 | PhpInterface::PHP_EXT; |
| 89 | - if(file_exists($entityFile)) |
|
| 89 | + if (file_exists($entityFile)) |
|
| 90 | 90 | { |
| 91 | 91 | $this->setPivotContent($relationEntity); |
| 92 | 92 | |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | MigrationsHelper::getTableName($relationEntity) . |
| 98 | 98 | PhpInterface::UNDERSCORE . ModelsInterface::MIGRATION_TABLE; |
| 99 | 99 | |
| 100 | - if(FileManager::migrationNotExists($this->generator, $migrationName)) |
|
| 100 | + if (FileManager::migrationNotExists($this->generator, $migrationName)) |
|
| 101 | 101 | { |
| 102 | 102 | $file = $this->generator->formatMigrationsPath() . $migrationMask |
| 103 | 103 | . PhpInterface::UNDERSCORE . $migrationName . PhpInterface::PHP_EXT; |
| 104 | 104 | // if migration file with the same name ocasionally exists we do not override it |
| 105 | 105 | $isCreated = FileManager::createFile($file, $this->sourceCode); |
| 106 | - if($isCreated) |
|
| 106 | + if ($isCreated) |
|
| 107 | 107 | { |
| 108 | 108 | Console::out($file . PhpInterface::SPACE . Console::CREATED, Console::COLOR_GREEN); |
| 109 | 109 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function openGroup() : void |
| 27 | 27 | { |
| 28 | - $versionNamespace = DirsInterface::MODULES_DIR . |
|
| 28 | + $versionNamespace = DirsInterface::MODULES_DIR . |
|
| 29 | 29 | PhpInterface::BACKSLASH . PhpInterface::BACKSLASH |
| 30 | 30 | . strtoupper($this->generator->version); |
| 31 | 31 | |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $data->map(function($v) { |
| 21 | 21 | $field = $this->bitMask->getField(); |
| 22 | - if(isset($v[$field])) { |
|
| 22 | + if (isset($v[$field])) { |
|
| 23 | 23 | $flags = $this->bitMask->getFlags(); |
| 24 | 24 | $mask = $v[$field]; |
| 25 | - foreach($flags as $flag => $fVal) { |
|
| 25 | + foreach ($flags as $flag => $fVal) { |
|
| 26 | 26 | $v[$flag] = (bool)($fVal & $mask); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | protected function setFlagsView(BaseModel $data) |
| 40 | 40 | { |
| 41 | 41 | $field = $this->bitMask->getField(); |
| 42 | - if(isset($data[$field])) { |
|
| 42 | + if (isset($data[$field])) { |
|
| 43 | 43 | $flags = $this->bitMask->getFlags(); |
| 44 | 44 | $mask = $data[$field]; |
| 45 | - foreach($flags as $flag => $fVal) { |
|
| 45 | + foreach ($flags as $flag => $fVal) { |
|
| 46 | 46 | $data[$flag] = ($fVal & $mask) ? true : false; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $field = $this->bitMask->getField(); |
| 60 | 60 | $flags = $this->bitMask->getFlags(); |
| 61 | - foreach($flags as $flag => $fVal) { |
|
| 61 | + foreach ($flags as $flag => $fVal) { |
|
| 62 | 62 | if (isset($jsonProps[$flag])) { |
| 63 | - if ((bool) $jsonProps[$flag] === true) { |
|
| 63 | + if ((bool)$jsonProps[$flag] === true) { |
|
| 64 | 64 | $this->model->$field |= $fVal; |
| 65 | - } else if ((bool) $jsonProps[$flag] === false) { |
|
| 65 | + } else if ((bool)$jsonProps[$flag] === false) { |
|
| 66 | 66 | $this->model->$field &= ~$fVal; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | protected function setFlagsCreate() |
| 78 | 78 | { |
| 79 | 79 | $field = $this->bitMask->getField(); |
| 80 | - if(isset($this->model->$field)) { |
|
| 80 | + if (isset($this->model->$field)) { |
|
| 81 | 81 | $flags = $this->bitMask->getFlags(); |
| 82 | 82 | $mask = $this->model->$field; |
| 83 | - foreach($flags as $flag => $fVal) { |
|
| 83 | + foreach ($flags as $flag => $fVal) { |
|
| 84 | 84 | $this->model->$flag = (bool)($fVal & $mask); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | $field = $this->bitMask->getField(); |
| 100 | 100 | $flags = $this->bitMask->getFlags(); |
| 101 | - foreach($flags as $flag => $fVal) { |
|
| 101 | + foreach ($flags as $flag => $fVal) { |
|
| 102 | 102 | if (isset($jsonProps[$flag])) { |
| 103 | - if ((bool) $jsonProps[$flag] === true) { |
|
| 103 | + if ((bool)$jsonProps[$flag] === true) { |
|
| 104 | 104 | $model->$field |= $fVal; |
| 105 | - } else if ((bool) $jsonProps[$flag] === false) { |
|
| 105 | + } else if ((bool)$jsonProps[$flag] === false) { |
|
| 106 | 106 | $model->$field &= ~$fVal; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | protected function setFlagsUpdate(&$model) : void |
| 119 | 119 | { |
| 120 | 120 | $field = $this->bitMask->getField(); |
| 121 | - if(isset($model[$field])) { |
|
| 121 | + if (isset($model[$field])) { |
|
| 122 | 122 | $flags = $this->bitMask->getFlags(); |
| 123 | 123 | $mask = $model[$field]; |
| 124 | - foreach($flags as $flag => $fVal) { |
|
| 124 | + foreach ($flags as $flag => $fVal) { |
|
| 125 | 125 | $model[$flag] = (bool)($fVal & $mask); |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -38,17 +38,14 @@ |
||
| 38 | 38 | private function setSqlOptions(Request $request) : SqlOptions |
| 39 | 39 | { |
| 40 | 40 | $sqlOptions = new SqlOptions(); |
| 41 | - $page = ($request->input(ModelsInterface::PARAM_PAGE) === null) ? $this->defaultPage : |
|
| 42 | - $request->input(ModelsInterface::PARAM_PAGE); |
|
| 43 | - $limit = ($request->input(ModelsInterface::PARAM_LIMIT) === null) ? $this->defaultLimit : |
|
| 44 | - $request->input(ModelsInterface::PARAM_LIMIT); |
|
| 41 | + $page = ($request->input(ModelsInterface::PARAM_PAGE) === null) ? $this->defaultPage : $request->input(ModelsInterface::PARAM_PAGE); |
|
| 42 | + $limit = ($request->input(ModelsInterface::PARAM_LIMIT) === null) ? $this->defaultLimit : $request->input(ModelsInterface::PARAM_LIMIT); |
|
| 45 | 43 | |
| 46 | 44 | if ($limit > ModelsInterface::MAX_LIMIT) { |
| 47 | 45 | throw new AttributesException(ErrorsInterface::JSON_API_ERRORS[ErrorsInterface::HTTP_PARAM_LIMIT], ErrorsInterface::HTTP_PARAM_LIMIT); |
| 48 | 46 | } |
| 49 | 47 | |
| 50 | - $sort = ($request->input(ModelsInterface::PARAM_SORT) === null) ? $this->defaultSort : |
|
| 51 | - $request->input(ModelsInterface::PARAM_SORT); |
|
| 48 | + $sort = ($request->input(ModelsInterface::PARAM_SORT) === null) ? $this->defaultSort : $request->input(ModelsInterface::PARAM_SORT); |
|
| 52 | 49 | |
| 53 | 50 | $data = ($request->input(ModelsInterface::PARAM_DATA) === NULL) ? ModelsInterface::DEFAULT_DATA |
| 54 | 51 | : Json::decode(urldecode($request->input(ModelsInterface::PARAM_DATA))); |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | { |
| 85 | 85 | // id must be there anyway |
| 86 | 86 | $this->data = $data; |
| 87 | - if(\in_array(ModelsInterface::ID, $this->data, true) === false) |
|
| 87 | + if (\in_array(ModelsInterface::ID, $this->data, true) === false) |
|
| 88 | 88 | { |
| 89 | 89 | $this->data[] = ModelsInterface::ID; |
| 90 | 90 | } |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $resource = $this->json->setMeta($meta)->getResource($this->formRequest, $item, $this->entity); |
| 166 | - return $this->getResponse(Json::prepareSerializedData($resource, $data)); |
|
| 166 | + return $this->getResponse(Json::prepareSerializedData($resource, $data)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $relEntity = ucfirst($relation); |
| 70 | - $formRequestEntity = $this->getFormRequestEntity(conf::getModuleName(), $relEntity); |
|
| 70 | + $formRequestEntity = $this->getFormRequestEntity(conf::getModuleName(), $relEntity); |
|
| 71 | 71 | $relFormRequest = new $formRequestEntity(); |
| 72 | 72 | |
| 73 | 73 | $this->json->setIsCollection($model->$relation instanceof \Illuminate\Database\Eloquent\Collection); |