File tree Expand file tree Collapse file tree 2 files changed +15
-31
lines changed
Expand file tree Collapse file tree 2 files changed +15
-31
lines changed Original file line number Diff line number Diff line change 44
55namespace Laminas \Db \Adapter \Mysql ;
66
7+ use Laminas \Db \Adapter \Driver \DriverInterface ;
8+ use Laminas \Db \Adapter \Exception ;
9+
710trait 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}
Original file line number Diff line number Diff line change 88use Laminas \Db \Adapter \Driver \Pdo \Result ;
99use Laminas \Db \Adapter \Driver \Pdo \Statement ;
1010use Laminas \Db \Adapter \Driver \Feature \AbstractFeature ;
11- use Laminas \Db \Adapter \Exception ;
11+ use Laminas \Db \Adapter \Mysql \ DatabasePlatformNameTrait ;
1212use Laminas \Db \Adapter \Profiler ;
1313
1414use function is_array ;
15- use function ucfirst ;
1615
1716class 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}
You can’t perform that action at this time.
0 commit comments