44
55namespace Cycle \ORM \Entity \Behavior \Identifier ;
66
7+ use Cycle \Database \DatabaseInterface ;
78use Cycle \ORM \Entity \Behavior \Schema \BaseModifier ;
89use Cycle \ORM \Entity \Behavior \Schema \RegistryModifier ;
910use Cycle \ORM \Schema \GeneratedField ;
1011use Cycle \Schema \Registry ;
11- use Ramsey \Identifier \SnowflakeFactory ;
1212
1313abstract class Snowflake extends BaseModifier
1414{
@@ -24,6 +24,7 @@ abstract class Snowflake extends BaseModifier
2424 public function compute (Registry $ registry ): void
2525 {
2626 $ modifier = new RegistryModifier ($ registry , $ this ->role );
27+ /** @var non-empty-string column */
2728 $ this ->column = $ modifier ->findColumnName ($ this ->field , $ this ->column );
2829 if (\is_string ($ this ->column ) && $ this ->column !== '' ) {
2930 $ modifier ->addSnowflakeColumn (
@@ -32,11 +33,9 @@ public function compute(Registry $registry): void
3233 $ this ->nullable ? null : GeneratedField::BEFORE_INSERT ,
3334 )->nullable ($ this ->nullable );
3435
35- $ factory = $ this ->snowflakeFactory ();
36-
3736 $ modifier ->setTypecast (
3837 $ registry ->getEntity ($ this ->role )->getFields ()->get ($ this ->field ),
39- [$ factory , 'createFromInteger ' ],
38+ [static ::class , 'fromInteger ' , $ this -> getTypecastArgs () ],
4039 );
4140 }
4241 }
@@ -54,13 +53,20 @@ public function render(Registry $registry): void
5453 $ this ->nullable ? null : GeneratedField::BEFORE_INSERT ,
5554 )->nullable ($ this ->nullable );
5655
57- $ factory = $ this ->snowflakeFactory ();
58-
5956 $ modifier ->setTypecast (
6057 $ registry ->getEntity ($ this ->role )->getFields ()->get ($ this ->field ),
61- [$ factory , 'createFromInteger ' ],
58+ [static ::class , 'fromInteger ' , $ this -> getTypecastArgs () ],
6259 );
6360 }
6461
65- abstract protected function snowflakeFactory (): SnowflakeFactory ;
62+ /**
63+ * @param int<0, max>|numeric-string $identifier
64+ */
65+ abstract public static function fromInteger (
66+ int |string $ identifier ,
67+ DatabaseInterface $ database ,
68+ array $ arguments ,
69+ ): \Ramsey \Identifier \Snowflake ;
70+
71+ abstract protected function getTypecastArgs (): array ;
6672}
0 commit comments