1 | <?php |
||
12 | class DbDumperFactory |
||
13 | { |
||
14 | /** |
||
15 | * @param string $dbConnectionName |
||
16 | * |
||
17 | * @return \Spatie\DbDumper\DbDumper |
||
18 | */ |
||
19 | public static function createFromConnection(string $dbConnectionName): DbDumper |
||
20 | { |
||
21 | $dbConfig = config("database.connections.{$dbConnectionName}"); |
||
22 | |||
23 | if (isset($dbConfig['read'])) { |
||
24 | $dbConfig = array_except( |
||
25 | array_merge($dbConfig, $dbConfig['read']), |
||
26 | ['read', 'write'] |
||
27 | ); |
||
28 | } |
||
29 | |||
30 | $dbDumper = static::forDriver($dbConfig['driver']) |
||
31 | ->setHost(array_first(array_wrap($dbConfig['host'] ?? ''))) |
||
32 | ->setDbName($dbConfig['database']) |
||
33 | ->setUserName($dbConfig['username'] ?? '') |
||
34 | ->setPassword($dbConfig['password'] ?? ''); |
||
35 | |||
36 | if ($dbDumper instanceof MySql) { |
||
37 | $dbDumper->setDefaultCharacterSet($dbConfig['charset'] ?? ''); |
||
38 | } |
||
39 | |||
40 | if (isset($dbConfig['port'])) { |
||
41 | $dbDumper = $dbDumper->setPort($dbConfig['port']); |
||
42 | } |
||
43 | |||
44 | if ($dbDumper instanceof MySql && config('backup.backup.dump_from_master') !== 'AUTO') { |
||
45 | $dbDumper = $dbDumper->setGtidPurged(config('backup.backup.dump_from_master') ?? 'AUTO'); |
||
|
|||
46 | } |
||
47 | |||
48 | if (isset($dbConfig['dump'])) { |
||
49 | $dbDumper = static::processExtraDumpParameters($dbConfig['dump'], $dbDumper); |
||
50 | } |
||
51 | |||
52 | return $dbDumper; |
||
53 | } |
||
54 | |||
55 | protected static function forDriver($dbDriver): DbDumper |
||
77 | |||
78 | /** |
||
79 | * @param array $dumpConfiguration |
||
80 | * |
||
81 | * @param $dbDumper |
||
82 | * |
||
83 | * @return mixed |
||
84 | */ |
||
85 | protected static function processExtraDumpParameters(array $dumpConfiguration, $dbDumper): DbDumper |
||
100 | |||
101 | /** |
||
102 | * @param \Spatie\DbDumper\DbDumper $dbDumper |
||
103 | * @param string $methodName |
||
104 | * @param string|null $methodValue |
||
105 | * |
||
106 | * @return \Spatie\DbDumper\DbDumper |
||
107 | */ |
||
108 | protected static function callMethodOnDumper(DbDumper $dbDumper, string $methodName, $methodValue): DbDumper |
||
120 | |||
121 | protected static function determineValidMethodName(DbDumper $dbDumper, string $methodName): string |
||
128 | } |
||
129 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.