Skip to content

Commit c9c075f

Browse files
committed
fix: fix PHPMD warnings and coderabbitai nitpicks
1 parent a8f3657 commit c9c075f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/MartinGeorgiev/Doctrine/DBAL/Types/Ltree.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ final class Ltree extends BaseType
1818
#[\Override]
1919
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
2020
{
21+
unset($column);
22+
2123
$this->assertPostgreSQLPlatform($platform);
2224

2325
return 'ltree';
@@ -26,6 +28,8 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
2628
#[\Override]
2729
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
2830
{
31+
$this->assertPostgreSQLPlatform($platform);
32+
2933
return [
3034
'ltree',
3135
];
@@ -75,7 +79,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
7579
private function assertPostgreSQLPlatform(AbstractPlatform $platform): void
7680
{
7781
if (!$platform instanceof PostgreSQLPlatform) {
78-
throw new \InvalidArgumentException('LtreeType can only be used with PostgreSQL platform.');
82+
throw new \LogicException('Ltree DBAL type can only be used with the PostgreSQL platform.');
7983
}
8084
}
8185
}

tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/LtreeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public function test_get_sql_declaration_throws_on_non_postgresql_platform(): vo
141141
$this->fixture->getSQLDeclaration([], self::createStub(AbstractPlatform::class));
142142
}
143143

144+
public function test_get_mapped_database_types_throws_on_non_postgresql_platform(): void
145+
{
146+
$this->expectException(\LogicException::class);
147+
$this->fixture->getMappedDatabaseTypes(self::createStub(AbstractPlatform::class));
148+
}
149+
144150
public function test_convert_to_database_value_throws_on_non_postgresql_platform(): void
145151
{
146152
$this->expectException(\LogicException::class);

0 commit comments

Comments
 (0)