1818
1919final class ReflectorFactory
2020{
21+ public const MODE_RECORDING = 'recording ' ;
22+
23+ public const MODE_REPLAY = 'replay ' ;
24+
25+ public const MODE_REPLAY_AND_RECORDING = 'replay-and-recording ' ;
26+
2127 public static function create (string $ cacheDir ): QueryReflector
2228 {
2329 // handle defaults
@@ -26,7 +32,7 @@ public static function create(string $cacheDir): QueryReflector
2632 $ user = getenv ('DBA_USER ' ) ?: 'root ' ;
2733 $ password = getenv ('DBA_PASSWORD ' ) ?: 'root ' ;
2834 $ dbname = getenv ('DBA_DATABASE ' ) ?: 'phpstan_dba ' ;
29- $ mode = getenv ('DBA_MODE ' ) ?: ' recording ' ;
35+ $ mode = getenv ('DBA_MODE ' ) ?: self :: MODE_RECORDING ;
3036 $ reflector = getenv ('DBA_REFLECTOR ' ) ?: 'mysqli ' ;
3137 } else {
3238 $ host = getenv ('DBA_HOST ' ) ?: $ _ENV ['DBA_HOST ' ];
@@ -61,7 +67,7 @@ public static function create(string $cacheDir): QueryReflector
6167 $ cacheFile
6268 );
6369
64- if (' recording ' === $ mode || ' replay-and-recording ' === $ mode ) {
70+ if (self :: MODE_RECORDING === $ mode || self :: MODE_REPLAY_AND_RECORDING === $ mode ) {
6571 $ schemaHasher = null ;
6672
6773 if ('mysqli ' === $ reflector ) {
@@ -79,7 +85,7 @@ public static function create(string $cacheDir): QueryReflector
7985 throw new \RuntimeException ('Unknown reflector: ' . $ reflector );
8086 }
8187
82- if (' replay-and-recording ' === $ mode ) {
88+ if (self :: MODE_REPLAY_AND_RECORDING === $ mode ) {
8389 if (null === $ schemaHasher ) {
8490 throw new \RuntimeException ('Schema hasher required. ' );
8591 }
@@ -95,7 +101,7 @@ public static function create(string $cacheDir): QueryReflector
95101 $ reflector
96102 );
97103 }
98- } elseif (' replay ' === $ mode ) {
104+ } elseif (self :: MODE_REPLAY === $ mode ) {
99105 $ reflector = new ReplayQueryReflector (
100106 $ reflectionCache
101107 );
0 commit comments