@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $pagination = $this->getPagination(); |
| 54 | 54 | |
| 55 | - if($pagination === false) { |
|
| 55 | + if ($pagination === false) { |
|
| 56 | 56 | $models = $this->queryRelationManager->all($this->db); |
| 57 | 57 | } else { |
| 58 | 58 | $limit = $pagination->getLimit(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $mainTable = $this->queryRelationManager->getTableCollection()->getMainTable(); |
| 64 | 64 | $pkFields = $mainTable->getPrimaryKeyForSelect(); |
| 65 | 65 | |
| 66 | - if(count($pkFields) === 1) { |
|
| 66 | + if (count($pkFields) === 1) { |
|
| 67 | 67 | $ids = $this->queryRelationManager |
| 68 | 68 | ->prepare() |
| 69 | 69 | ->getQuery() |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | ->all(); |
| 88 | 88 | |
| 89 | 89 | $pkValuesPrefixed = []; |
| 90 | - foreach($pkValues as $row) { |
|
| 90 | + foreach ($pkValues as $row) { |
|
| 91 | 91 | $rowPrefixed = []; |
| 92 | - foreach($row as $field => $value) { |
|
| 92 | + foreach ($row as $field => $value) { |
|
| 93 | 93 | $rowPrefixed["{$mainTable->alias}.{$field}"] = $value; |
| 94 | 94 | } |
| 95 | 95 | $pkValuesPrefixed[] = $rowPrefixed; |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | protected function prepareKeys($models): array |
| 115 | 115 | { |
| 116 | - if($this->key !== null) { |
|
| 116 | + if ($this->key !== null) { |
|
| 117 | 117 | /** @var array<scalar> $keys */ |
| 118 | 118 | $keys = []; |
| 119 | 119 | |
| 120 | - foreach($models as $model) { |
|
| 121 | - if(is_string($this->key)) { |
|
| 120 | + foreach ($models as $model) { |
|
| 121 | + if (is_string($this->key)) { |
|
| 122 | 122 | $keys[] = $model[$this->key]; |
| 123 | 123 | } else { |
| 124 | 124 | $keys[] = call_user_func($this->key, $model); |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function prepareTotalCount(): int |
| 139 | 139 | { |
| 140 | - if($this->withoutTotalCount) { |
|
| 140 | + if ($this->withoutTotalCount) { |
|
| 141 | 141 | return 0; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return (int)$this->queryRelationManager |
|
| 144 | + return (int) $this->queryRelationManager |
|
| 145 | 145 | ->prepare() |
| 146 | 146 | ->getQuery() |
| 147 | 147 | ->select($this->queryRelationManager->getTableCollection()->getMainTable()->getPrimaryKeyForSelect()) |
@@ -44,40 +44,40 @@ discard block |
||
| 44 | 44 | $parentAlias = $parentAlias ?? $mainTable->alias; |
| 45 | 45 | $parentClassName = $this->tableCollection->byAlias($parentAlias)->className; |
| 46 | 46 | |
| 47 | - if(!class_exists($parentClassName)) { |
|
| 47 | + if (!class_exists($parentClassName)) { |
|
| 48 | 48 | throw new QueryRelationManagerException("class {$parentClassName} not exists"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** @var ActiveRecord $inst */ |
| 52 | 52 | $inst = new $parentClassName(); |
| 53 | - if(!($inst instanceof ActiveRecord)) { |
|
| 53 | + if (!($inst instanceof ActiveRecord)) { |
|
| 54 | 54 | throw new QueryRelationManagerException("class {$parentClassName} is not an instance of ActiveRecord"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $methodName = 'get'.ucfirst($relationName); |
| 58 | - if(!method_exists($inst, $methodName)) { |
|
| 58 | + if (!method_exists($inst, $methodName)) { |
|
| 59 | 59 | throw new QueryRelationManagerException("method {$parentClassName}::{$methodName}() not exists"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** @var ActiveQuery $activeQuery */ |
| 63 | 63 | $activeQuery = $inst->$methodName(); |
| 64 | - if(!($activeQuery instanceof ActiveQuery)) { |
|
| 64 | + if (!($activeQuery instanceof ActiveQuery)) { |
|
| 65 | 65 | throw new QueryRelationManagerException( |
| 66 | 66 | "method {$parentClassName}::{$methodName}() returned non-ActiveQuery instance" |
| 67 | 67 | ); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if($activeQuery->via) { |
|
| 70 | + if ($activeQuery->via) { |
|
| 71 | 71 | throw new QueryRelationManagerException('cannot use relations with "via" section yet'); |
| 72 | 72 | } |
| 73 | - if(!is_array($activeQuery->link) || !count($activeQuery->link)) { |
|
| 73 | + if (!is_array($activeQuery->link) || !count($activeQuery->link)) { |
|
| 74 | 74 | throw new QueryRelationManagerException('cannot use relations without "link" section'); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** @var string $className */ |
| 78 | 78 | $className = $activeQuery->modelClass; |
| 79 | 79 | |
| 80 | - if($activeQuery->multiple) { |
|
| 80 | + if ($activeQuery->multiple) { |
|
| 81 | 81 | return $this->withMultiple( |
| 82 | 82 | $relationName, |
| 83 | 83 | $className, |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function getTableName(string $className): string |
| 132 | 132 | { |
| 133 | - if(!method_exists($className, 'tableName')) { |
|
| 133 | + if (!method_exists($className, 'tableName')) { |
|
| 134 | 134 | throw new QueryRelationManagerException( |
| 135 | 135 | "method {$className}::tableName() is not defined" |
| 136 | 136 | ); |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function getTableFields(string $className): array |
| 155 | 155 | { |
| 156 | - if(!class_exists($className)) { |
|
| 156 | + if (!class_exists($className)) { |
|
| 157 | 157 | throw new QueryRelationManagerException("class {$className} is not defined"); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if(!method_exists($className, 'getTableSchema')) { |
|
| 160 | + if (!method_exists($className, 'getTableSchema')) { |
|
| 161 | 161 | throw new QueryRelationManagerException("method {$className}::getTableSchema() is not defined"); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | protected function getPrimaryKey(string $className): array |
| 173 | 173 | { |
| 174 | - if(!class_exists($className)) { |
|
| 174 | + if (!class_exists($className)) { |
|
| 175 | 175 | throw new QueryRelationManagerException("class {$className} is not defined"); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if(!method_exists($className, 'primaryKey')) { |
|
| 178 | + if (!method_exists($className, 'primaryKey')) { |
|
| 179 | 179 | throw new QueryRelationManagerException("method {$className}::primaryKey() is not defined"); |
| 180 | 180 | } |
| 181 | 181 | |