@@ -159,10 +159,10 @@ |
||
| 159 | 159 | public function newEntity(array $data): EntityInterface |
| 160 | 160 | { |
| 161 | 161 | $entity = $this->getHydrator() |
| 162 | - ->hydrate(array_merge( |
|
| 163 | - $this->getConfig()->getDefaultEntityAttributes(), |
|
| 164 | - $data |
|
| 165 | - )); |
|
| 162 | + ->hydrate(array_merge( |
|
| 163 | + $this->getConfig()->getDefaultEntityAttributes(), |
|
| 164 | + $data |
|
| 165 | + )); |
|
| 166 | 166 | |
| 167 | 167 | return $this->behaviours->apply($this, __FUNCTION__, $entity); |
| 168 | 168 | } |
@@ -65,86 +65,86 @@ |
||
| 65 | 65 | public static function varchar(string $name, $length = 255) |
| 66 | 66 | { |
| 67 | 67 | return static::make($name) |
| 68 | - ->setType(static::TYPE_VARCHAR) |
|
| 69 | - ->setLength($length); |
|
| 68 | + ->setType(static::TYPE_VARCHAR) |
|
| 69 | + ->setLength($length); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public static function bool(string $name) |
| 73 | 73 | { |
| 74 | 74 | return static::make($name) |
| 75 | - ->setType(static::TYPE_BOOLEAN); |
|
| 75 | + ->setType(static::TYPE_BOOLEAN); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public static function string(string $name) |
| 79 | 79 | { |
| 80 | 80 | return static::make($name) |
| 81 | - ->setType(static::TYPE_TEXT); |
|
| 81 | + ->setType(static::TYPE_TEXT); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public static function datetime(string $name) |
| 85 | 85 | { |
| 86 | 86 | return static::make($name) |
| 87 | - ->setType(static::TYPE_DATETIME); |
|
| 87 | + ->setType(static::TYPE_DATETIME); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public static function date(string $name) |
| 91 | 91 | { |
| 92 | 92 | return static::make($name) |
| 93 | - ->setType(static::TYPE_DATE); |
|
| 93 | + ->setType(static::TYPE_DATE); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public static function timestamp(string $name) |
| 97 | 97 | { |
| 98 | 98 | return static::make($name) |
| 99 | - ->setType(static::TYPE_TIMESTAMP); |
|
| 99 | + ->setType(static::TYPE_TIMESTAMP); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public static function json(string $name) |
| 103 | 103 | { |
| 104 | 104 | return static::make($name) |
| 105 | - ->setType(static::TYPE_JSON); |
|
| 105 | + ->setType(static::TYPE_JSON); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public static function float(string $name) |
| 109 | 109 | { |
| 110 | 110 | return static::make($name) |
| 111 | - ->setType(static::TYPE_FLOAT); |
|
| 111 | + ->setType(static::TYPE_FLOAT); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public static function integer(string $name, $unsigned = false) |
| 115 | 115 | { |
| 116 | 116 | return static::make($name) |
| 117 | - ->setType(static::TYPE_INTEGER) |
|
| 118 | - ->setUnsigned($unsigned); |
|
| 117 | + ->setType(static::TYPE_INTEGER) |
|
| 118 | + ->setUnsigned($unsigned); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public static function tinyInteger(string $name, $unsigned = false) |
| 122 | 122 | { |
| 123 | 123 | return static::make($name) |
| 124 | - ->setType(static::TYPE_TINY_INTEGER) |
|
| 125 | - ->setUnsigned($unsigned); |
|
| 124 | + ->setType(static::TYPE_TINY_INTEGER) |
|
| 125 | + ->setUnsigned($unsigned); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public static function smallInteger(string $name, $unsigned = false) |
| 129 | 129 | { |
| 130 | 130 | return static::make($name) |
| 131 | - ->setType(static::TYPE_SMALL_INTEGER) |
|
| 132 | - ->setUnsigned($unsigned); |
|
| 131 | + ->setType(static::TYPE_SMALL_INTEGER) |
|
| 132 | + ->setUnsigned($unsigned); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public static function bigInteger(string $name, $unsigned = false) |
| 136 | 136 | { |
| 137 | 137 | return static::make($name) |
| 138 | - ->setType(static::TYPE_BIG_INTEGER) |
|
| 139 | - ->setUnsigned($unsigned); |
|
| 138 | + ->setType(static::TYPE_BIG_INTEGER) |
|
| 139 | + ->setUnsigned($unsigned); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function decimal(string $name, int $digits, int $precision) |
| 143 | 143 | { |
| 144 | 144 | return static::make($name) |
| 145 | - ->setType(static::TYPE_DECIMAL) |
|
| 146 | - ->setDigits($digits) |
|
| 147 | - ->setPrecision($precision); |
|
| 145 | + ->setType(static::TYPE_DECIMAL) |
|
| 146 | + ->setDigits($digits) |
|
| 147 | + ->setPrecision($precision); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if ($this->deletedAtColumn && ! array_key_exists($this->deletedAtColumn, $columns)) { |
| 48 | 48 | $mapper->addColumn(Column::datetime($this->deletedAtColumn) |
| 49 | - ->setNullable(true)); |
|
| 49 | + ->setNullable(true)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | return $this; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $class->getNamespace()->addUse(\Sirius\Orm\Action\Delete::class, 'DeleteAction'); |
| 59 | 59 | $class->getNamespace()->addUse(\Sirius\Orm\Action\Update::class, 'UpdateAction'); |
| 60 | 60 | $class->addProperty('deletedAtColumn', $this->deletedAtColumn) |
| 61 | - ->setVisibility('protected'); |
|
| 61 | + ->setVisibility('protected'); |
|
| 62 | 62 | |
| 63 | 63 | // |
| 64 | 64 | $method = $class->addMethod('newDeleteAction'); |
@@ -123,21 +123,21 @@ discard block |
||
| 123 | 123 | public function observeBaseQueryClass(ClassType $class): ClassType |
| 124 | 124 | { |
| 125 | 125 | $class->addProperty('deletedAtColumn', $this->deletedAtColumn) |
| 126 | - ->setVisibility('protected'); |
|
| 126 | + ->setVisibility('protected'); |
|
| 127 | 127 | |
| 128 | 128 | // add guard |
| 129 | 129 | if ( ! $class->hasMethod('init')) { |
| 130 | 130 | $class->addMethod('init') |
| 131 | - ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
| 132 | - ->setBody('parent::init();' . PHP_EOL); |
|
| 131 | + ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
| 132 | + ->setBody('parent::init();' . PHP_EOL); |
|
| 133 | 133 | } |
| 134 | 134 | $init = $class->getMethod('init'); |
| 135 | 135 | $init->addBody('$this->guards[] = $this->deletedAtColumn . \' IS NULL\';' . PHP_EOL); |
| 136 | 136 | |
| 137 | 137 | // add withTrashed() |
| 138 | 138 | $class->addMethod('withTrashed') |
| 139 | - ->setVisibility(ClassType::VISIBILITY_PUBLIC) |
|
| 140 | - ->setBody(' |
|
| 139 | + ->setVisibility(ClassType::VISIBILITY_PUBLIC) |
|
| 140 | + ->setBody(' |
|
| 141 | 141 | $guards = []; |
| 142 | 142 | foreach ($this->guards as $k => $v) { |
| 143 | 143 | if ($v != $this->deletedAtColumn . \' IS NULL\') { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | $insertSql = new \Sirius\Sql\Insert($connection); |
| 31 | 31 | $insertSql->into($this->mapper->getConfig()->getTable()) |
| 32 | - ->columns($columns); |
|
| 32 | + ->columns($columns); |
|
| 33 | 33 | $insertSql->perform(); |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | $update = new \Sirius\Sql\Update($this->mapper->getWriteConnection()); |
| 25 | 25 | $update->table($this->mapper->getConfig()->getTable()) |
| 26 | - ->columns([ |
|
| 27 | - $this->getOption('deleted_at_column') => $this->now |
|
| 28 | - ]) |
|
| 29 | - ->where('id', $entityId); |
|
| 26 | + ->columns([ |
|
| 27 | + $this->getOption('deleted_at_column') => $this->now |
|
| 28 | + ]) |
|
| 29 | + ->where('id', $entityId); |
|
| 30 | 30 | $update->perform(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -122,8 +122,8 @@ |
||
| 122 | 122 | |
| 123 | 123 | $insert = new \Sirius\Sql\Insert($conn); |
| 124 | 124 | $insert->into($throughTable) |
| 125 | - ->columns($insertColumns) |
|
| 126 | - ->perform(); |
|
| 125 | + ->columns($insertColumns) |
|
| 126 | + ->perform(); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | protected function getNativeEntityHydrator() |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | if (count($columns) > 0) { |
| 55 | 55 | $updateSql = new \Sirius\Sql\Update($connection); |
| 56 | 56 | $updateSql->table($this->mapper->getConfig()->getTable()) |
| 57 | - ->columns($columns) |
|
| 58 | - ->whereAll($conditions, false); |
|
| 57 | + ->columns($columns) |
|
| 58 | + ->whereAll($conditions, false); |
|
| 59 | 59 | $updateSql->perform(); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | private function addFirstMethod() |
| 65 | 65 | { |
| 66 | 66 | $method = $this->class->addMethod('first') |
| 67 | - ->setReturnNullable(true) |
|
| 68 | - ->setReturnType($this->mapper->getEntityClass()); |
|
| 67 | + ->setReturnNullable(true) |
|
| 68 | + ->setReturnType($this->mapper->getEntityClass()); |
|
| 69 | 69 | $method->setBody('return parent::first();'); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $this->namespace->addUse(Collection::class); |
| 75 | 75 | $method = $this->class->addMethod('get') |
| 76 | - ->setReturnType('Collection'); |
|
| 76 | + ->setReturnType('Collection'); |
|
| 77 | 77 | $method->setBody('return parent::get();'); |
| 78 | 78 | $method->addComment(sprintf('@return Collection|%s[]', $this->mapper->getEntityClass())); |
| 79 | 79 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $this->namespace->addUse(PaginatedCollection::class); |
| 84 | 84 | $method = $this->class->addMethod('paginate') |
| 85 | - ->setReturnType('PaginatedCollection'); |
|
| 85 | + ->setReturnType('PaginatedCollection'); |
|
| 86 | 86 | $method->addParameter('perPage')->setType('int'); |
| 87 | 87 | $method->addParameter('page', 1)->setType('int'); |
| 88 | 88 | $method->setBody('return parent::paginate($perPage, $page);'); |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $this->namespace->addUse($this->mapper->getEntityNamespace() . '\\' . $this->mapper->getEntityClass()); |
| 149 | 149 | $method = $this->class->addMethod('find') |
| 150 | - ->setReturnNullable(true) |
|
| 151 | - ->setReturnType($this->mapper->getEntityClass()); |
|
| 150 | + ->setReturnNullable(true) |
|
| 151 | + ->setReturnType($this->mapper->getEntityClass()); |
|
| 152 | 152 | $method->addParameter('pk'); |
| 153 | 153 | $method->addParameter('load', [])->setType('array'); |
| 154 | 154 | $method->setBody('return parent::find($pk, $load);'); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | protected function addNewQueryMethod() |
| 158 | 158 | { |
| 159 | 159 | $method = $this->class->addMethod('newQuery') |
| 160 | - ->setReturnType($this->mapper->getQueryClass()); |
|
| 160 | + ->setReturnType($this->mapper->getQueryClass()); |
|
| 161 | 161 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this);', $this->mapper->getQueryClass())); |
| 162 | 162 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
| 163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $this->namespace->addUse(Update::class, 'UpdateAction'); |
| 171 | 171 | |
| 172 | 172 | $method = $this->class->addMethod('save') |
| 173 | - ->setReturnType('bool'); |
|
| 173 | + ->setReturnType('bool'); |
|
| 174 | 174 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
| 175 | 175 | $method->addParameter('withRelations', false); |
| 176 | 176 | $method->setBody(' |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | protected function addDeleteMethod() |
| 209 | 209 | { |
| 210 | 210 | $method = $this->class->addMethod('delete') |
| 211 | - ->setReturnType('bool'); |
|
| 211 | + ->setReturnType('bool'); |
|
| 212 | 212 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
| 213 | 213 | $method->addParameter('withRelations', false); |
| 214 | 214 | $method->setBody(' |