File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ .idea /
2
+ vendor /
3
+ composer.lock
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " neutronstars/dotrine-enum-php-type" ,
3
+ "description" : " Added an enumeration system as close as possible to PHP 8.1 for earlier versions." ,
4
+ "type" : " library" ,
5
+ "license" : [ " Apache-2.0" ],
6
+ "authors" : [
7
+ {
8
+ "name" : " NeutronStars" ,
9
+ "email" : " pro@neutronstars.fr"
10
+ }
11
+ ],
12
+ "autoload" : {
13
+ "psr-4" : {
14
+ "NeutronStars\\ Doctrine\\ Enum\\ Type\\ " : " src/"
15
+ }
16
+ },
17
+ "minimum-stability" : " stable" ,
18
+ "require" : {
19
+ "php" : " ^7.1 | ^8.0" ,
20
+ "doctrine/dbal" : " ^2.1" ,
21
+ "neutronstars/enum" : " ^1.4"
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace NeutronStars \Doctrine \Enum \Type ;
6
+
7
+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
8
+ use Doctrine \DBAL \Types \Type ;
9
+ use Doctrine \DBAL \Types \Types ;
10
+ use NeutronStars \Enum \Enum ;
11
+
12
+ abstract class EnumType extends Type
13
+ {
14
+ public function getSQLDeclaration (array $ column , AbstractPlatform $ platform ): string
15
+ {
16
+ return Types::STRING ;
17
+ }
18
+
19
+ public function convertToDatabaseValue ($ value , AbstractPlatform $ platform ): ?string
20
+ {
21
+ return ($ value instanceof Enum) ? (string ) $ value : null ;
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments