Skip to content

Commit

Permalink
Merge cc47bd3 into 77288e5
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Dec 8, 2021
2 parents 77288e5 + cc47bd3 commit 6f4c73e
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 407 deletions.
28 changes: 19 additions & 9 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
* Pattern fluent pour la création et configuration des types de données.
*
* @author Mathieu NOËL <mathieu@soosyze.com>
*
* @phpstan-type FieldToArray array{
* _comment?: string,
* default?: null|scalar,
* length?: int,
* nullable?: bool,
* opt?: string,
* type: string,
* unsigned?: bool,
* }
*/
abstract class Field
{
Expand All @@ -33,7 +43,7 @@ abstract class Field
protected const INVALID_ARGUMENT_MESSAGE = 'The value of the %s field must be of type %s: %s given.';

/**
* @var bool|null|numeric|string
* @var null|scalar
*/
protected $valueDefault;

Expand Down Expand Up @@ -92,19 +102,19 @@ public function nullable(): self
* Enregistre une valeur par défaut au champ précédent.
* Lève une exception si la valeur par défaut ne correspond pas au type de valeur passée en paramètre.
*
* @param bool|null|numeric|string $value Valeur à tester.
* @param null|scalar $value Valeur à tester.
*
* @throws ColumnsValueException
*
* @return bool|null|numeric|string
* @return null|scalar
*/
abstract public function filterValue($value);

/**
* Enregistre une valeur par défaut au champ précédent.
* Lève une exception si la valeur par défaut ne correspond pas au type de valeur passée en paramètre.
*
* @param bool|null|numeric|string $value Valeur à tester.
* @param null|scalar $value Valeur à tester.
*
* @throws TableBuilderException
*
Expand All @@ -122,7 +132,7 @@ public function valueDefault($value)
*
* @throws ColumnsValueException
*
* @return bool|null|numeric|string Valeur par defaut.
* @return null|scalar Valeur par defaut.
*/
public function getValueDefault()
{
Expand Down Expand Up @@ -179,13 +189,13 @@ public function setName(string $name): self
* Retourne les données du champ.
*
* @return array
*
* @phpstan-return FieldToArray
*/
public function toArray(): array
{
$data = [];
if (static::TYPE !== '') {
$data[ 'type' ] = static::TYPE;
}
$data[ 'type' ] = static::TYPE;

if ($this->isNullable) {
$data[ 'nullable' ] = $this->isNullable;
}
Expand Down
2 changes: 0 additions & 2 deletions src/Field/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

namespace Queryflatfile\Field;

use Queryflatfile\Field;

/**
* @author Mathieu NOËL <mathieu@soosyze.com>
*/
Expand Down
Loading

0 comments on commit 6f4c73e

Please sign in to comment.