@@ -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()) |
@@ -58,29 +58,29 @@ discard block |
||
58 | 58 | /** @var ActiveRecord $inst */ |
59 | 59 | $inst = new $parentClassName(); |
60 | 60 | $methodName = 'get'.ucfirst($relationName); |
61 | - if(!method_exists($inst, $methodName)) { |
|
61 | + if (!method_exists($inst, $methodName)) { |
|
62 | 62 | throw new QueryRelationManagerException("method {$parentClassName}::{$methodName}() not exists"); |
63 | 63 | } |
64 | 64 | |
65 | 65 | /** @var ActiveQuery $activeQuery */ |
66 | 66 | $activeQuery = $inst->$methodName(); |
67 | - if(!($activeQuery instanceof ActiveQuery)) { |
|
67 | + if (!($activeQuery instanceof ActiveQuery)) { |
|
68 | 68 | throw new QueryRelationManagerException( |
69 | 69 | "method {$parentClassName}::{$methodName}() returned non-ActiveQuery instance" |
70 | 70 | ); |
71 | 71 | } |
72 | 72 | |
73 | - if($activeQuery->via) { |
|
73 | + if ($activeQuery->via) { |
|
74 | 74 | throw new QueryRelationManagerException('cannot use relations with "via" section yet'); |
75 | 75 | } |
76 | - if(!is_array($activeQuery->link) || !count($activeQuery->link)) { |
|
76 | + if (!is_array($activeQuery->link) || !count($activeQuery->link)) { |
|
77 | 77 | throw new QueryRelationManagerException('cannot use relations without "link" section'); |
78 | 78 | } |
79 | 79 | |
80 | 80 | /** @var string $className */ |
81 | 81 | $className = $activeQuery->modelClass; |
82 | 82 | |
83 | - if($activeQuery->multiple) { |
|
83 | + if ($activeQuery->multiple) { |
|
84 | 84 | return $this->withMultiple( |
85 | 85 | $relationName, |
86 | 86 | $className, |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected static function checkClassIsActiveRecord(string $className) |
125 | 125 | { |
126 | - if(!class_exists($className)) { |
|
126 | + if (!class_exists($className)) { |
|
127 | 127 | throw new QueryRelationManagerException( |
128 | 128 | "class '{$className}' does not exist" |
129 | 129 | ); |
130 | 130 | } |
131 | 131 | |
132 | - if(!(new $className() instanceof ActiveRecord)) { |
|
132 | + if (!(new $className() instanceof ActiveRecord)) { |
|
133 | 133 | throw new QueryRelationManagerException( |
134 | 134 | "class {$className} is not an instance of ActiveRecord" |
135 | 135 | ); |