@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $this->values = []; |
| 52 | 52 | $colNames = implode(",", $this->columns); |
| 53 | 53 | $rows = $this->connection->query("SELECT $colNames FROM " . $this->table->getName())->fetchAll(); |
| 54 | - foreach ($rows as $row){ |
|
| 54 | + foreach ($rows as $row) { |
|
| 55 | 55 | $pk = []; |
| 56 | - foreach ($this->columns as $column){ |
|
| 56 | + foreach ($this->columns as $column) { |
|
| 57 | 57 | $pk[$column] = $row[$column]; |
| 58 | 58 | } |
| 59 | 59 | $this->values[] = $pk; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $keys = array_keys($value); |
| 73 | 73 | sort($keys); |
| 74 | - if ($this->columns == $keys){ |
|
| 74 | + if ($this->columns == $keys) { |
|
| 75 | 75 | throw new PrimaryKeyColumnMismatchException("PrimaryKeys do not match between PKStore and addValue"); |
| 76 | 76 | } |
| 77 | 77 | $this->values[] = $value; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getRandomValue() : array |
| 84 | 84 | { |
| 85 | - return $this->values[random_int(0, count($this->values) -1)]; |
|
| 85 | + return $this->values[random_int(0, count($this->values) - 1)]; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | /* Don't hesitate to use the Faker package to generate random data, |
| 20 | 20 | there is plenty of data types available (IBAN, address, country code, ...). |
| 21 | 21 | */ |
| 22 | -$dataFaker = \Faker\Factory::create();//you could pass the locale to generate localized data ! |
|
| 22 | +$dataFaker = \Faker\Factory::create(); //you could pass the locale to generate localized data ! |
|
| 23 | 23 | |
| 24 | 24 | // address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code : |
| 25 | 25 | $generatorFinderBuilder->addGenerator( |
| 26 | - new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
| 26 | + new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
| 27 | 27 | return $table->getName() == "address" && $column->getName() == "postal_code"; |
| 28 | 28 | }), |
| 29 | 29 | function() use ($dataFaker){ |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // all columns that end with "_email" or are named exactly "email" should be emails |
| 35 | 35 | $generatorFinderBuilder->addGenerator( |
| 36 | - new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
| 36 | + new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
| 37 | 37 | return preg_match("/([(.*_)|_|]|^)email$/", $column->getName()) === 1; |
| 38 | 38 | }), |
| 39 | 39 | function() use ($dataFaker){ |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | "community_spending" => 100, |
| 50 | 50 | "cron_flag" => 10, |
| 51 | 51 | "project" => 50, |
| 52 | - "project_note" => 200 , |
|
| 52 | + "project_note" => 200, |
|
| 53 | 53 | "project_steps" => 10, |
| 54 | 54 | "project_tasks" => 35, |
| 55 | 55 | "request_hollidays" => 20, |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ->column("population")->bigInt() |
| 61 | 61 | ->column("birthrate")->float() |
| 62 | 62 | ->column("president_id")->references("persons") |
| 63 | - ->column("population_density")->decimal(10,2) |
|
| 63 | + ->column("population_density")->decimal(10, 2) |
|
| 64 | 64 | ->column("summary")->text(); |
| 65 | 65 | |
| 66 | 66 | $users->column("country_id")->references("countries"); |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | /* Don't hesitate to use the Faker package to generate random data, |
| 104 | 104 | there is plenty of data types available (IBAN, address, country code, ...). |
| 105 | 105 | */ |
| 106 | - $dataFaker = \Faker\Factory::create();//you could pass the locale to generate localized data ! |
|
| 106 | + $dataFaker = \Faker\Factory::create(); //you could pass the locale to generate localized data ! |
|
| 107 | 107 | |
| 108 | 108 | // address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code : |
| 109 | 109 | $generatorFinderBuilder->addGenerator( |
| 110 | - new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
| 110 | + new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
| 111 | 111 | return $table->getName() == "address" && $column->getName() == "postal_code"; |
| 112 | 112 | }), |
| 113 | 113 | new SimpleGenerator( |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // all columns that end with "_email" or are named exactly "email" should be emails |
| 121 | 121 | $generatorFinderBuilder->addGenerator( |
| 122 | - new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
| 122 | + new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
| 123 | 123 | return preg_match("/([(.*_)|_|]|^)email$/", $column->getName()) === 1; |
| 124 | 124 | }), |
| 125 | 125 | new SimpleGenerator( |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class CheckTypeConditionTest extends TestCase |
| 10 | 10 | { |
| 11 | - public function testCanApply(){ |
|
| 11 | + public function testCanApply() { |
|
| 12 | 12 | $table = new Table("foo"); |
| 13 | 13 | $column = new Column("bar", Type::getType(Type::DECIMAL)); |
| 14 | 14 | |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct(Column $column) |
| 36 | 36 | { |
| 37 | - if (array_search($column->getType()->getName(), self::$handledNumberTypes) === false){ |
|
| 37 | + if (array_search($column->getType()->getName(), self::$handledNumberTypes) === false) { |
|
| 38 | 38 | throw new UnsupportedDataTypeException("Unsupported column type : " . |
| 39 | 39 | $column->getType()->getName() . "only " . |
| 40 | - implode("', '", self::$handledNumberTypes) ." types are supported." |
|
| 40 | + implode("', '", self::$handledNumberTypes) . " types are supported." |
|
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | $this->column = $column; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function getMinNumericValue() |
| 51 | 51 | { |
| 52 | 52 | $precisionValue = $this->getAbsValueByLengthPrecision($this->column); |
| 53 | - switch ($this->column->getType()->getName()){ |
|
| 53 | + switch ($this->column->getType()->getName()) { |
|
| 54 | 54 | case Type::BIGINT: |
| 55 | 55 | return $this->column->getUnsigned() ? 0 : bcpow(2, 63); |
| 56 | 56 | break; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | public function getMaxNumericValue() |
| 77 | 77 | { |
| 78 | 78 | $precisionValue = $this->getAbsValueByLengthPrecision($this->column); |
| 79 | - switch ($this->column->getType()->getName()){ |
|
| 79 | + switch ($this->column->getType()->getName()) { |
|
| 80 | 80 | case Type::BIGINT: |
| 81 | 81 | return $this->column->getUnsigned() ? bcpow(2, 64) : bcpow(2, 63) - 1; |
| 82 | 82 | case Type::INTEGER: |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | private function getAbsValueByLengthPrecision(Column $column) |
| 98 | 98 | { |
| 99 | - switch ($column->getType()->getName()){ |
|
| 99 | + switch ($column->getType()->getName()) { |
|
| 100 | 100 | case Type::DECIMAL: |
| 101 | 101 | $str = str_repeat(9, $column->getScale()); |
| 102 | 102 | return (double) substr_replace($str, ".", $column->getScale() - $column->getPrecision(), 0); |
@@ -20,11 +20,11 @@ |
||
| 20 | 20 | public function __invoke(Column $column) |
| 21 | 21 | { |
| 22 | 22 | $files = glob($this->globExpression, GLOB_MARK); |
| 23 | - $files = array_filter($files, function ($fileName){ |
|
| 23 | + $files = array_filter($files, function($fileName) { |
|
| 24 | 24 | return strrpos($fileName, DIRECTORY_SEPARATOR) !== strlen($fileName) - 1; |
| 25 | 25 | }); |
| 26 | - if (count($files) == 0){ |
|
| 27 | - throw new NoTestFilesFoundException("No files found for glob expression '".$this->globExpression."'"); |
|
| 26 | + if (count($files) == 0) { |
|
| 27 | + throw new NoTestFilesFoundException("No files found for glob expression '" . $this->globExpression . "'"); |
|
| 28 | 28 | } |
| 29 | 29 | $files = array_values($files); |
| 30 | 30 | $chosenFile = $files[random_int(0, count($files) - 1)]; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct(Type $type) |
| 23 | 23 | { |
| 24 | - if (!Type::hasType($type)){ |
|
| 24 | + if (!Type::hasType($type)) { |
|
| 25 | 25 | throw new UnsupportedDataTypeException("Type '$$type' is not supported, please add it to DBAL types list (see Type::addType())"); |
| 26 | 26 | } |
| 27 | 27 | $this->type = Type::getType($type); |
@@ -27,14 +27,14 @@ |
||
| 27 | 27 | public function findGenerator(Table $table, Column $column) : FakeDataGeneratorInterface |
| 28 | 28 | { |
| 29 | 29 | $generator = null; |
| 30 | - if (!isset($this->generators[$table->getName() . "." . $column->getName()])){ |
|
| 31 | - foreach ($this->generatorFactories as list($condition, $generatorFactory)){ |
|
| 30 | + if (!isset($this->generators[$table->getName() . "." . $column->getName()])) { |
|
| 31 | + foreach ($this->generatorFactories as list($condition, $generatorFactory)) { |
|
| 32 | 32 | /** @var $condition ConditionInterface */ |
| 33 | - if ($condition->canApply($table, $column)){ |
|
| 33 | + if ($condition->canApply($table, $column)) { |
|
| 34 | 34 | $generator = $generatorFactory->create($table, $column); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | - if (!$generator){ |
|
| 37 | + if (!$generator) { |
|
| 38 | 38 | throw new UnsupportedDataTypeException("Could not find suitable generator for column " . $table->getName() . "." . $column->getName() . " of type : " . $column->getType()->getName()); |
| 39 | 39 | } |
| 40 | 40 | $this->generators[$table->getName() . "." . $column->getName()] = $generator; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | public function __construct(string $fakerProperty, $generateUniqueValues = false) |
| 23 | 23 | { |
| 24 | 24 | $this->faker = Factory::create(); |
| 25 | - if ($generateUniqueValues){ |
|
| 25 | + if ($generateUniqueValues) { |
|
| 26 | 26 | $this->faker->unique(); |
| 27 | 27 | } |
| 28 | 28 | $this->fakerProperty = $fakerProperty; |