diff --git a/composer.json b/composer.json index 01e52df..9950539 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ } ], "require": { + "php": ">=7.1", "mikehaertl/php-shellcommand": "1.*", "yiisoft/yii2": "2.*", "schmunk42/retry" : "*" diff --git a/db/helper/CliHelper.php b/db/helper/CliHelper.php index e324b0a..6d95b50 100644 --- a/db/helper/CliHelper.php +++ b/db/helper/CliHelper.php @@ -7,11 +7,10 @@ * file that was distributed with this source code. */ - namespace dmstr\db\helper; - use mikehaertl\shellcommand\Command; +use yii\base\Exception; use yii\db\Connection; /** @@ -24,9 +23,12 @@ */ class CliHelper { + public static function getMysqlCommand($mysqlExecutable = 'mysql', ?Connection $db = null) + { + if ($db === null) { + throw new Exception('Invalid database config'); + } - - public static function getMysqlCommand($mysqlExecutable = 'mysql', $db){ $dsnOpts = CliHelper::getMysqlOptsFromDsn($db); $command = new Command($mysqlExecutable); @@ -54,7 +56,7 @@ public static function getMysqlOptsFromDsn(Connection $db) $cliArgs = [ 'host' => null, - 'db' => null, + 'db' => null, 'port' => 3306, ]; @@ -101,4 +103,4 @@ public static function getMysqlCliArgsFromPdo(Connection $db) return $cliArgs; } -} \ No newline at end of file +}