-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from skeets23/master
Allow "enum" type
Showing
2 changed files
with
63 additions
and
3 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
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,39 @@ | ||
<?php | ||
|
||
namespace Mpociot\LaravelTestFactoryHelper\Types; | ||
|
||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
|
||
class EnumType extends Type | ||
{ | ||
|
||
const ENUM = 'enum'; | ||
|
||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) | ||
{ | ||
/* | ||
* This is wrong, but it also isn't important, since we're not modifying | ||
* tables anyways. This method must exist to match the abstract parent | ||
* class, but we won't use it. Normally, this should return the SQL | ||
* required to create an 'enum' column, but since this function doesn't | ||
* know the values of the enum field, that's not possible. | ||
*/ | ||
return 'ENUM'; | ||
} | ||
|
||
public function convertToPHPValue($value, AbstractPlatform $platform) | ||
{ | ||
return $value; | ||
} | ||
|
||
public function convertToDatabaseValue($value, AbstractPlatform $platform) | ||
{ | ||
return $value; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return self::ENUM; | ||
} | ||
} |