@@ -13,7 +13,7 @@ |
||
13 | 13 | $extraction_table = $extraction_class::table(); |
14 | 14 | |
15 | 15 | foreach ($extraction_table->columns() as $column_name => $column) { |
16 | - $probe_name = $extraction_class::tableAlias() . '_' . $column_name; |
|
16 | + $probe_name = $extraction_class::tableAlias().'_'.$column_name; |
|
17 | 17 | |
18 | 18 | if (!is_null($probe_res = $from_model->get($probe_name))) { |
19 | 19 | $extract_model->set($column_name, $probe_res); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | public function __construct(string $class) |
15 | 15 | { |
16 | - if(class_exists($class) === false) |
|
16 | + if (class_exists($class) === false) |
|
17 | 17 | throw new \Exception('CLASS_NOT_FOUND'); |
18 | 18 | |
19 | 19 | $this->class = $class; |
@@ -13,8 +13,9 @@ |
||
13 | 13 | |
14 | 14 | public function __construct(string $class) |
15 | 15 | { |
16 | - if(class_exists($class) === false) |
|
17 | - throw new \Exception('CLASS_NOT_FOUND'); |
|
16 | + if(class_exists($class) === false) { |
|
17 | + throw new \Exception('CLASS_NOT_FOUND'); |
|
18 | + } |
|
18 | 19 | |
19 | 20 | $this->class = $class; |
20 | 21 | $this->table = $this->class::table(); |
@@ -51,10 +51,10 @@ |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | if (isset($options['limit'])) { |
54 | - if(is_array($options['limit'])){ |
|
54 | + if (is_array($options['limit'])) { |
|
55 | 55 | $this->statement()->limit($options['limit'][0], $options['limit'][1]); |
56 | 56 | } |
57 | - elseif(is_numeric($options['limit'])){ |
|
57 | + elseif (is_numeric($options['limit'])) { |
|
58 | 58 | $this->statement()->limit($options['limit']); |
59 | 59 | } |
60 | 60 | } |
@@ -53,8 +53,7 @@ |
||
53 | 53 | if (isset($options['limit'])) { |
54 | 54 | if(is_array($options['limit'])){ |
55 | 55 | $this->statement()->limit($options['limit'][0], $options['limit'][1]); |
56 | - } |
|
57 | - elseif(is_numeric($options['limit'])){ |
|
56 | + } elseif(is_numeric($options['limit'])){ |
|
58 | 57 | $this->statement()->limit($options['limit']); |
59 | 58 | } |
60 | 59 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __toString() |
14 | 14 | { |
15 | - return static::class_short_name() . ' #' . $this->id(); |
|
15 | + return static::class_short_name().' #'.$this->id(); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function nid(): string |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function urn(): string |
24 | 24 | { |
25 | - return $this->nid() . ':' . $this->id(); |
|
25 | + return $this->nid().':'.$this->id(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function immortal(): bool |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public static function tableAlias(): string |
162 | 162 | { |
163 | - if (defined(get_called_class() . '::TABLE_ALIAS')) { |
|
163 | + if (defined(get_called_class().'::TABLE_ALIAS')) { |
|
164 | 164 | return get_called_class()::TABLE_ALIAS; |
165 | 165 | } |
166 | 166 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | public static function model_type(): string |
171 | 171 | { |
172 | - if (defined(get_called_class() . '::MODEL_TYPE')) { |
|
172 | + if (defined(get_called_class().'::MODEL_TYPE')) { |
|
173 | 173 | return get_called_class()::MODEL_TYPE; |
174 | 174 | } |
175 | 175 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function import($assoc_data): self |
66 | 66 | { |
67 | 67 | if (!is_array($assoc_data)) { |
68 | - throw new \Exception(__FUNCTION__ . '(assoc_data) parm is not an array'); |
|
68 | + throw new \Exception(__FUNCTION__.'(assoc_data) parm is not an array'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // shove it all up in model, god will sort them out |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (($table_name = $called_class->getConstant('TABLE_NAME')) !== false) |
89 | 89 | return $table_name; |
90 | 90 | |
91 | - if (defined($const_name = 'TABLE_' . strtoupper($class_name))) |
|
91 | + if (defined($const_name = 'TABLE_'.strtoupper($class_name))) |
|
92 | 92 | return constant($const_name); |
93 | 93 | |
94 | 94 | // fallback to convention |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | $model_data = get_object_vars($this); |
105 | 105 | |
106 | - if($this->isNew()){ |
|
106 | + if ($this->isNew()) { |
|
107 | 107 | // $table_row = new Row($this, $model_data); |
108 | 108 | $table_row = new Row($this->schema, static::table(), $model_data); |
109 | 109 | } |
110 | - else{ |
|
110 | + else { |
|
111 | 111 | $table_row = new Row($this->schema); |
112 | 112 | $table_row->load($model_data); |
113 | 113 | } |
@@ -85,11 +85,13 @@ discard block |
||
85 | 85 | $class_name = $called_class->getShortName(); |
86 | 86 | |
87 | 87 | // try constants |
88 | - if (($table_name = $called_class->getConstant('TABLE_NAME')) !== false) |
|
89 | - return $table_name; |
|
88 | + if (($table_name = $called_class->getConstant('TABLE_NAME')) !== false) { |
|
89 | + return $table_name; |
|
90 | + } |
|
90 | 91 | |
91 | - if (defined($const_name = 'TABLE_' . strtoupper($class_name))) |
|
92 | - return constant($const_name); |
|
92 | + if (defined($const_name = 'TABLE_' . strtoupper($class_name))) { |
|
93 | + return constant($const_name); |
|
94 | + } |
|
93 | 95 | |
94 | 96 | // fallback to convention |
95 | 97 | return strtolower($class_name); |
@@ -106,8 +108,7 @@ discard block |
||
106 | 108 | if($this->isNew()){ |
107 | 109 | // $table_row = new Row($this, $model_data); |
108 | 110 | $table_row = new Row($this->schema, static::table(), $model_data); |
109 | - } |
|
110 | - else{ |
|
111 | + } else{ |
|
111 | 112 | $table_row = new Row($this->schema); |
112 | 113 | $table_row->load($model_data); |
113 | 114 | } |
@@ -168,8 +169,9 @@ discard block |
||
168 | 169 | else if (is_scalar($arg1) && count($table->primaryKeys()) === 1) { |
169 | 170 | $pk = current($table->primaryKeys())->name(); |
170 | 171 | $unique_identifiers = [$pk => $arg1]; |
171 | - } else |
|
172 | - throw new CruditesException('ARGUMENTS_ARE_NOT_ACTIONNABLE'); |
|
172 | + } else { |
|
173 | + throw new CruditesException('ARGUMENTS_ARE_NOT_ACTIONNABLE'); |
|
174 | + } |
|
173 | 175 | |
174 | 176 | |
175 | 177 | // Find the unique identifier(s) in the database. |