| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 84 | public function initialize(string $database, bool $ignoreIndexNames, bool $ignoreForeignKeyNames) |
||
| 85 | { |
||
| 86 | /** @var MigrationGeneratorSetting $setting */ |
||
| 87 | $setting = resolve(MigrationGeneratorSetting::class); |
||
| 88 | |||
| 89 | $this->registerCustomDoctrineType(DoubleType::class, 'double', 'double'); |
||
| 90 | $this->registerCustomDoctrineType(EnumType::class, 'enum', 'enum'); |
||
| 91 | $this->registerCustomDoctrineType(GeometryType::class, 'geometry', 'geometry'); |
||
| 92 | $this->registerCustomDoctrineType(GeometryCollectionType::class, 'geometrycollection', 'geometrycollection'); |
||
| 93 | $this->registerCustomDoctrineType(LineStringType::class, 'linestring', 'linestring'); |
||
| 94 | $this->registerCustomDoctrineType(LongTextType::class, 'longtext', 'longtext'); |
||
| 95 | $this->registerCustomDoctrineType(MediumIntegerType::class, 'mediumint', 'mediumint'); |
||
| 96 | $this->registerCustomDoctrineType(MediumTextType::class, 'mediumtext', 'mediumtext'); |
||
| 97 | $this->registerCustomDoctrineType(MultiLineStringType::class, 'multilinestring', 'multilinestring'); |
||
| 98 | $this->registerCustomDoctrineType(MultiPointType::class, 'multipoint', 'multipoint'); |
||
| 99 | $this->registerCustomDoctrineType(MultiPolygonType::class, 'multipolygon', 'multipolygon'); |
||
| 100 | $this->registerCustomDoctrineType(PointType::class, 'point', 'point'); |
||
| 101 | $this->registerCustomDoctrineType(PolygonType::class, 'polygon', 'polygon'); |
||
| 102 | $this->registerCustomDoctrineType(SetType::class, 'set', 'set'); |
||
| 103 | $this->registerCustomDoctrineType(TimestampType::class, 'timestamp', 'timestamp'); |
||
| 104 | $this->registerCustomDoctrineType(UUIDType::class, 'uuid', 'uuid'); |
||
| 105 | $this->registerCustomDoctrineType(YearType::class, 'year', 'year'); |
||
| 106 | |||
| 107 | // Postgres types |
||
| 108 | $this->registerCustomDoctrineType(IpAddressType::class, 'ipaddress', 'inet'); |
||
| 109 | $this->registerCustomDoctrineType(JsonbType::class, 'jsonb', 'jsonb'); |
||
| 110 | $this->registerCustomDoctrineType(MacAddressType::class, 'macaddress', 'macaddr'); |
||
| 111 | $this->registerCustomDoctrineType(TimeTzType::class, 'timetz', 'timetz'); |
||
| 112 | $this->registerCustomDoctrineType(TimestampTzType::class, 'timestamptz', 'timestamptz'); |
||
| 113 | |||
| 114 | /** @var \Doctrine\DBAL\Connection $connection */ |
||
| 115 | $connection = DB::connection($database)->getDoctrineConnection(); |
||
| 116 | |||
| 117 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('bit', 'boolean'); |
||
| 118 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'json'); |
||
| 119 | |||
| 120 | switch ($setting->getPlatform()) { |
||
| 121 | case Platform::POSTGRESQL: |
||
| 122 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('_text', 'text'); |
||
| 123 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('_int4', 'integer'); |
||
| 124 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('_numeric', 'float'); |
||
| 125 | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('cidr', 'string'); |
||
| 126 | break; |
||
| 127 | default: |
||
| 128 | } |
||
| 129 | |||
| 130 | $this->database = $connection->getDatabase(); |
||
| 131 | |||
| 132 | $this->schema = $connection->getSchemaManager(); |
||
| 133 | |||
| 134 | $this->ignoreIndexNames = $ignoreIndexNames; |
||
| 135 | $this->ignoreForeignKeyNames = $ignoreForeignKeyNames; |
||
| 136 | } |
||
| 137 | |||
| 185 |