-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create resolvers for categorizing columns
- Loading branch information
Showing
50 changed files
with
1,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BIGINT(size) | ||
* | ||
* A large integer. | ||
* Signed range is from -9223372036854775808 to 9223372036854775807. | ||
* Unsigned range is from 0 to 18446744073709551615. | ||
* The size parameter specifies the maximum display width (which is 255) | ||
*/ | ||
class BigintResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->numerify(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: bigIncrements() | ||
// TODO: $table->foreignId('user_id'); | ||
// TODO: $table->foreignIdFor(User::class); | ||
// TODO: $table->id(); | ||
// TODO: $table->unsignedBigInteger('votes'); | ||
$migration = '$table->bigInteger(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BINARY(size) | ||
* | ||
* Equal to CHAR(), but stores binary byte strings. | ||
* The size parameter specifies the column length in bytes. | ||
* Default is 1 | ||
*/ | ||
class BinaryResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->sha1(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->binary(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BIT(size) | ||
* | ||
* A bit-value type. | ||
* The number of bits per value is specified in size. | ||
* The size parameter can hold a value from 1 to 64. | ||
* The default value for size is 1. | ||
*/ | ||
final class BitResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->numberBetween(1, 64),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->integer(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BLOB(size) | ||
* | ||
* For BLOBs (Binary Large OBjects). | ||
* Holds up to 65,535 bytes of data | ||
*/ | ||
final class BlobResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->sha1(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->binary(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BOOL | ||
* | ||
* Zero is considered as false, nonzero values are considered as true. | ||
*/ | ||
class BoolResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->boolean(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->boolean(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* BOOLEAN | ||
* | ||
* Equal to BOOL | ||
*/ | ||
final class BooleanResolver extends BoolResolver | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* CHAR(size) | ||
* | ||
* A FIXED length string (can contain letters, numbers, and special characters). | ||
* The size parameter specifies the column length in characters - can be from 0 to 255. | ||
* Default is 1 | ||
*/ | ||
class CharResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->randomLetter(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->char(\''.$this->column->field.'\', '.$this->column->bracket.')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* DATE | ||
* | ||
* A date. Format: YYYY-MM-DD. | ||
* The supported range is from '1000-01-01' to '9999-12-31' | ||
*/ | ||
class DateResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->date(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->date(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* DATETIME(fsp) | ||
* | ||
* A date and time combination. | ||
* Format: YYYY-MM-DD hh:mm:ss. | ||
* The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. | ||
* Adding DEFAULT and ON UPDATE in the column definition to get automatic initialization and updating to the current date and time | ||
*/ | ||
class DatetimeResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->dateTime(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: dateTimeTz | ||
$migration = '$table->dateTime(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* Equal to DECIMAL(size,d) | ||
*/ | ||
class DecResolver extends DecimalResolver | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* DECIMAL(size, d) | ||
* | ||
* An exact fixed-point number. | ||
* The total number of digits is specified in size. | ||
* The number of digits after the decimal point is specified in the d parameter. | ||
* The maximum number for size is 65. | ||
* The maximum number for d is 30. | ||
* The default value for size is 10. | ||
* The default value for d is 0. | ||
*/ | ||
class DecimalResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->randomFloat(2, 0, 10000),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: $table->decimal('amount', $precision = 8, $scale = 2); | ||
// TODO: $table->unsignedDecimal('amount', $precision = 8, $scale = 2); | ||
$migration = '$table->decimal(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* DOUBLE(size, d) | ||
* | ||
* A normal-size floating point number. | ||
* The total number of digits is specified in size. | ||
* The number of digits after the decimal point is specified in the d parameter | ||
*/ | ||
class DoubleResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->randomFloat(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: $table->double('amount', 8, 2); | ||
$migration = '$table->double(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* ENUM(val1, val2, val3, ...) | ||
* | ||
* A string object that can have only one value, chosen from a list of possible values. | ||
* You can list up to 65535 values in an ENUM list. | ||
* If a value is inserted that is not in the list, a blank value will be inserted. | ||
* The values are sorted in the order you enter them | ||
*/ | ||
class EnumResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
// TODO: Replace 1,2,3 with real values | ||
return '\''.$this->column->field.'\' => fake()->randomElements(1,2,3),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: $table->enum('difficulty', ['easy', 'hard']); | ||
$migration = '$table->enum(\''.$this->column->field.'\', '.$this->column->bracket.')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* FLOAT(size, d) | ||
* | ||
* A floating point number. | ||
* The total number of digits is specified in size. | ||
* The number of digits after the decimal point is specified in the d parameter. | ||
* This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions | ||
* | ||
* FLOAT(p) | ||
* | ||
* A floating point number. | ||
* MySQL uses the p value to determine whether to use FLOAT or DOUBLE for the resulting data type. | ||
* If p is from 0 to 24, the data type becomes FLOAT(). | ||
* If p is from 25 to 53, the data type becomes DOUBLE() | ||
*/ | ||
class FloatResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
return '\''.$this->column->field.'\' => fake()->randomFloat(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
// TODO: $table->float('amount', 8, 2); | ||
$migration = '$table->float(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Cable8mm\Xeed\Resolvers; | ||
|
||
/** | ||
* GEOMETRY | ||
*/ | ||
class GeometryResolver extends Resolver | ||
{ | ||
public function fake(): string | ||
{ | ||
// TODO: Understanding GEOMETRY, then implement this method for it | ||
return '\''.$this->column->field.'\' => fake()->numerify(),'; | ||
} | ||
|
||
public function migration(): string | ||
{ | ||
$migration = '$table->geometry(\''.$this->column->field.'\')'; | ||
|
||
return $this->last($migration); | ||
} | ||
} |
Oops, something went wrong.