@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | return [ |
| 73 | 73 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 74 | 74 | 'contents' => $this->classPrinter->printFile($file) |
| 75 | - . PHP_EOL |
|
| 76 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 77 | - . $this->classPrinter->printClass($class) |
|
| 75 | + . PHP_EOL |
|
| 76 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 77 | + . $this->classPrinter->printClass($class) |
|
| 78 | 78 | ]; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | return [ |
| 94 | 94 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 95 | 95 | 'contents' => $this->classPrinter->printFile($file) |
| 96 | - . PHP_EOL |
|
| 97 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 98 | - . $this->classPrinter->printClass($class) |
|
| 96 | + . PHP_EOL |
|
| 97 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 98 | + . $this->classPrinter->printClass($class) |
|
| 99 | 99 | ]; |
| 100 | 100 | |
| 101 | 101 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | return [ |
| 111 | 111 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 112 | 112 | 'contents' => $this->classPrinter->printFile($file) |
| 113 | - . PHP_EOL |
|
| 114 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 115 | - . $this->classPrinter->printClass($class) |
|
| 113 | + . PHP_EOL |
|
| 114 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 115 | + . $this->classPrinter->printClass($class) |
|
| 116 | 116 | ]; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | return [ |
| 133 | 133 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 134 | 134 | 'contents' => $this->classPrinter->printFile($file) |
| 135 | - . PHP_EOL |
|
| 136 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 137 | - . $this->classPrinter->printClass($class) |
|
| 135 | + . PHP_EOL |
|
| 136 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 137 | + . $this->classPrinter->printClass($class) |
|
| 138 | 138 | ]; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | return [ |
| 153 | 153 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
| 154 | 154 | 'contents' => $this->classPrinter->printFile($file) |
| 155 | - . PHP_EOL |
|
| 156 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 157 | - . $this->classPrinter->printClass($class) |
|
| 155 | + . PHP_EOL |
|
| 156 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 157 | + . $this->classPrinter->printClass($class) |
|
| 158 | 158 | ]; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | return [ |
| 175 | 175 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
| 176 | 176 | 'contents' => $this->classPrinter->printFile($file) |
| 177 | - . PHP_EOL |
|
| 178 | - . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 179 | - . $this->classPrinter->printClass($class) |
|
| 177 | + . PHP_EOL |
|
| 178 | + . ($class->getNamespace() ? $this->classPrinter->printNamespace($class->getNamespace()) : '') |
|
| 179 | + . $this->classPrinter->printClass($class) |
|
| 180 | 180 | ]; |
| 181 | 181 | |
| 182 | 182 | } |
@@ -363,7 +363,7 @@ |
||
| 363 | 363 | { |
| 364 | 364 | return $this->addColumn( |
| 365 | 365 | Column::integer($name, true) |
| 366 | - ->setAutoIncrement(true) |
|
| 366 | + ->setAutoIncrement(true) |
|
| 367 | 367 | ); |
| 368 | 368 | } |
| 369 | 369 | |
@@ -64,35 +64,35 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $errors = []; |
| 66 | 66 | |
| 67 | - if ( ! $this->table) { |
|
| 67 | + if (!$this->table) { |
|
| 68 | 68 | $errors[] = 'Missing table property'; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( ! $this->className) { |
|
| 71 | + if (!$this->className) { |
|
| 72 | 72 | $errors[] = 'Missing class name property'; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ($this->destination) { |
| 76 | - if ( ! is_dir($this->destination)) { |
|
| 76 | + if (!is_dir($this->destination)) { |
|
| 77 | 77 | $errors[] = sprintf('%s is not a valid directory', $this->destination); |
| 78 | - } elseif ( ! is_writable($this->destination)) { |
|
| 78 | + } elseif (!is_writable($this->destination)) { |
|
| 79 | 79 | $errors[] = sprintf('%s is not writable', $this->destination); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! $this->entityClass) { |
|
| 83 | + if (!$this->entityClass) { |
|
| 84 | 84 | $errors[] = 'Missing entity class name property'; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | if ($this->entityDestination) { |
| 88 | - if ( ! is_dir($this->entityDestination)) { |
|
| 88 | + if (!is_dir($this->entityDestination)) { |
|
| 89 | 89 | $errors[] = sprintf('%s is not a valid directory', $this->entityDestination); |
| 90 | - } elseif ( ! is_writable($this->entityDestination)) { |
|
| 90 | + } elseif (!is_writable($this->entityDestination)) { |
|
| 91 | 91 | $errors[] = sprintf('%s is not writable', $this->entityDestination); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if ( ! is_array($this->columns) || empty($this->columns)) { |
|
| 95 | + if (!is_array($this->columns) || empty($this->columns)) { |
|
| 96 | 96 | $errors[] = 'Missing columns definitions'; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | public function addRelation($name, Relation $relation) |
| 419 | 419 | { |
| 420 | 420 | $relation->setMapper($this); |
| 421 | - if ( ! $relation->getForeignMapper()) { |
|
| 421 | + if (!$relation->getForeignMapper()) { |
|
| 422 | 422 | $relation->setForeignMapper(Inflector::pluralize($name)); |
| 423 | 423 | } |
| 424 | 424 | $this->relations[$name] = $relation; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | public function addQueryScope($name, QueryScope $queryScope) |
| 434 | 434 | { |
| 435 | 435 | $queryScope->setMapper($this); |
| 436 | - if ( ! $queryScope->getName()) { |
|
| 436 | + if (!$queryScope->getName()) { |
|
| 437 | 437 | $queryScope->setName($name); |
| 438 | 438 | } |
| 439 | 439 | $this->queryScopes[$name] = $queryScope; |
@@ -460,19 +460,19 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | $singular = Inflector::singularize($name); |
| 462 | 462 | |
| 463 | - if ( ! $this->table) { |
|
| 463 | + if (!$this->table) { |
|
| 464 | 464 | $this->setTable($name); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if ($this->table !== $name && ! $this->tableAlias) { |
|
| 467 | + if ($this->table !== $name && !$this->tableAlias) { |
|
| 468 | 468 | $this->setTableAlias($name); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if ( ! $this->className) { |
|
| 471 | + if (!$this->className) { |
|
| 472 | 472 | $this->setClassName(Str::className($singular) . 'Mapper'); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( ! $this->entityClass) { |
|
| 475 | + if (!$this->entityClass) { |
|
| 476 | 476 | $this->setEntityClass(Str::className($singular)); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | static public function make($createdAtColumn = 'created_at', $updatedAtColumn = 'updated_at') |
| 19 | 19 | { |
| 20 | 20 | return (new static) |
| 21 | - ->setCreatedAtColumn($createdAtColumn) |
|
| 22 | - ->setUpdatedAtColumn($updatedAtColumn); |
|
| 21 | + ->setCreatedAtColumn($createdAtColumn) |
|
| 22 | + ->setUpdatedAtColumn($updatedAtColumn); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function getName(): string |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if ($this->createdAtColumn && ! array_key_exists($this->createdAtColumn, $columns)) { |
| 61 | 61 | $mapper->addColumn(Column::datetime($this->createdAtColumn) |
| 62 | - ->setNullable(true)); |
|
| 62 | + ->setNullable(true)); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if ($this->updatedAtColumn && ! array_key_exists($this->updatedAtColumn, $columns)) { |
| 66 | 66 | $mapper->addColumn(Column::datetime($this->updatedAtColumn) |
| 67 | - ->setNullable(true) |
|
| 68 | - ->setAfter($this->createdAtColumn)); |
|
| 67 | + ->setNullable(true) |
|
| 68 | + ->setAfter($this->createdAtColumn)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this; |
@@ -74,35 +74,35 @@ discard block |
||
| 74 | 74 | public function observeBaseQueryClass(ClassType $class): ClassType |
| 75 | 75 | { |
| 76 | 76 | $class->addProperty('createdAtColumn', $this->createdAtColumn) |
| 77 | - ->setVisibility('protected'); |
|
| 77 | + ->setVisibility('protected'); |
|
| 78 | 78 | $class->addProperty('updatedAtColumn', $this->updatedAtColumn) |
| 79 | - ->setVisibility('protected'); |
|
| 79 | + ->setVisibility('protected'); |
|
| 80 | 80 | |
| 81 | 81 | // add methods |
| 82 | 82 | $class->addMethod('orderByFirstCreated') |
| 83 | - ->setVisibility('public') |
|
| 84 | - ->setBody(' |
|
| 83 | + ->setVisibility('public') |
|
| 84 | + ->setBody(' |
|
| 85 | 85 | $this->orderBy($this->createdAtColumn . \' ASC\'); |
| 86 | 86 | |
| 87 | 87 | return $this; |
| 88 | 88 | '); |
| 89 | 89 | $class->addMethod('orderByLastCreated') |
| 90 | - ->setVisibility('public') |
|
| 91 | - ->setBody(' |
|
| 90 | + ->setVisibility('public') |
|
| 91 | + ->setBody(' |
|
| 92 | 92 | $this->orderBy($this->createdAtColumn . \' DESC\'); |
| 93 | 93 | |
| 94 | 94 | return $this; |
| 95 | 95 | '); |
| 96 | 96 | $class->addMethod('orderByFirstUpdated') |
| 97 | - ->setVisibility('public') |
|
| 98 | - ->setBody(' |
|
| 97 | + ->setVisibility('public') |
|
| 98 | + ->setBody(' |
|
| 99 | 99 | $this->orderBy($this->updatedAtColumn . \' ASC\'); |
| 100 | 100 | |
| 101 | 101 | return $this; |
| 102 | 102 | '); |
| 103 | 103 | $class->addMethod('orderByLastCreated') |
| 104 | - ->setVisibility('public') |
|
| 105 | - ->setBody(' |
|
| 104 | + ->setVisibility('public') |
|
| 105 | + ->setBody(' |
|
| 106 | 106 | $this->orderBy($this->updatedAtColumn . \' DESC\'); |
| 107 | 107 | |
| 108 | 108 | return $this; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if ( ! $class->hasMethod('init')) { |
| 120 | 120 | $class->addMethod('init')->setVisibility('public') |
| 121 | - ->setBody('parent::init();' . PHP_EOL); |
|
| 121 | + ->setBody('parent::init();' . PHP_EOL); |
|
| 122 | 122 | } |
| 123 | 123 | $class->getNamespace()->addUse(\Sirius\Orm\Behaviour\Timestamps::class); |
| 124 | 124 | $method = $class->getMethod('init'); |