Skip to content

Commit fb639db

Browse files
committed
stash local changes prior to pulling code from @simon-mundy
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent ef509e1 commit fb639db

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

src/DatabasePlatformNameTrait.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Laminas\Db\Adapter\Mysql;
66

7+
use Laminas\Db\Adapter\Driver\DriverInterface;
8+
use Laminas\Db\Adapter\Exception;
9+
710
trait DatabasePlatformNameTrait
811
{
912
/**
@@ -12,12 +15,18 @@ trait DatabasePlatformNameTrait
1215
* @param string $nameFormat
1316
* @return string
1417
*/
15-
public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
18+
public function getDatabasePlatformName($nameFormat = DriverInterface::NAME_FORMAT_CAMELCASE)
1619
{
17-
if ($nameFormat === self::NAME_FORMAT_CAMELCASE) {
20+
if ($nameFormat === DriverInterface::NAME_FORMAT_CAMELCASE) {
1821
return 'Mysql';
1922
}
2023

21-
return 'MySQL';
24+
if ($nameFormat === DriverInterface::NAME_FORMAT_NATURAL) {
25+
return 'MySQL';
26+
}
27+
28+
throw new Exception\InvalidArgumentException(
29+
'Invalid name format provided. Must be one of: ' . DriverInterface::NAME_FORMAT_CAMELCASE . ', ' . DriverInterface::NAME_FORMAT_NATURAL
30+
);
2231
}
2332
}

src/Driver/Pdo/Pdo.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
use Laminas\Db\Adapter\Driver\Pdo\Result;
99
use Laminas\Db\Adapter\Driver\Pdo\Statement;
1010
use Laminas\Db\Adapter\Driver\Feature\AbstractFeature;
11-
use Laminas\Db\Adapter\Exception;
11+
use Laminas\Db\Adapter\Mysql\DatabasePlatformNameTrait;
1212
use Laminas\Db\Adapter\Profiler;
1313

1414
use function is_array;
15-
use function ucfirst;
1615

1716
class Pdo extends AbstractPdo
1817
{
18+
use DatabasePlatformNameTrait;
19+
1920
/**
2021
* @param array|Connection|\PDO $connection
2122
* @param string $features
@@ -102,30 +103,4 @@ public function getFeature($name)
102103
}
103104
return false;
104105
}
105-
106-
/**
107-
* Get database platform name
108-
*
109-
* @param string $nameFormat
110-
* @return string
111-
*/
112-
public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE): string
113-
{
114-
$name = $this->getConnection()->getDriverName();
115-
116-
if ($nameFormat === self::NAME_FORMAT_CAMELCASE) {
117-
return ucfirst($name);
118-
}
119-
120-
if ($nameFormat === self::NAME_FORMAT_NATURAL) {
121-
return match ($name) {
122-
'mysql' => 'MySQL',
123-
default => ucfirst($name),
124-
};
125-
}
126-
127-
throw new Exception\InvalidArgumentException(
128-
'Invalid name format provided. Must be one of: ' . self::NAME_FORMAT_CAMELCASE . ', ' . self::NAME_FORMAT_NATURAL
129-
);
130-
}
131106
}

0 commit comments

Comments
 (0)