diff --git a/.travis.yml b/.travis.yml index 7b88444..29f349d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,14 @@ -language: php - -php: - - 5.5 - - 5.6 - - 7.0 - - hhvm - -matrix: - allow_failures: - - php: 7.0 - -before_script: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev - -script: phpunit \ No newline at end of file +language: php + +php: + - 7.2 + - 7.3 + - 7.4 + +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev + +script: + - ./vendor/bin/phpcs --standard=phpcs.xml src + - ./vendor/bin/phpstan --level=0 --no-progress analyse src diff --git a/composer.json b/composer.json index 24806cf..07db68d 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,18 @@ "require": { "php": "^7.2", "illuminate/support": "^6.0|^7.0|^8.0", + "illuminate/console": "^6.0|^7.0|^8.0", "illuminate/cache": "^6.0|^7.0|^8.0" }, "suggest": { "illuminate/database": "Allows for storing of currencies in the database" }, + "require-dev": { + "phpunit/phpunit": "^8.0", + "mockery/mockery": "^1.3", + "phpstan/phpstan": "^0.12.14", + "squizlabs/php_codesniffer": "^3.5" + }, "autoload": { "files": [ "src/helpers.php" diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..6ca6aac --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,26 @@ + + + The PSR2 standard + + + /resources/ + /vendor/ + /_[a-zA-Z0-9\._]+\.php + /\.[a-zA-Z0-9\._]+\.php + \.git + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..567a070 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + excludes_analyse: + - vendor + - resources + ignoreErrors: + - '#Function app not found#' + - '#Function config_path not found#' + - '#Function base_path not found#' + - '#Function config not found#' + - '#Parameter \$request of method#' diff --git a/src/Console/Manage.php b/src/Console/Manage.php index c050419..35e3548 100644 --- a/src/Console/Manage.php +++ b/src/Console/Manage.php @@ -82,7 +82,8 @@ public function handle() protected function add($currency) { if (($data = $this->getCurrency($currency)) === null) { - return $this->error("Currency \"{$currency}\" not found"); + $this->error("Currency \"{$currency}\" not found"); + return; } $this->output->write("Adding {$currency} currency..."); @@ -106,7 +107,8 @@ protected function add($currency) protected function update($currency) { if (($data = $this->getCurrency($currency)) === null) { - return $this->error("Currency \"{$currency}\" not found"); + $this->error("Currency \"{$currency}\" not found"); + return; } $this->output->write("Updating {$currency} currency..."); diff --git a/src/CurrencyServiceProvider.php b/src/CurrencyServiceProvider.php index 38eb9bf..1aa7d5c 100644 --- a/src/CurrencyServiceProvider.php +++ b/src/CurrencyServiceProvider.php @@ -1,85 +1,85 @@ -registerCurrency(); - - if ($this->app->runningInConsole()) { - $this->registerResources(); - $this->registerCurrencyCommands(); - } - } - - /** - * Register currency provider. - * - * @return void - */ - public function registerCurrency() - { - $this->app->singleton('currency', function ($app) { - return new Currency( - $app->config->get('currency', []), - $app['cache'] - ); - }); - } - - /** - * Register currency resources. - * - * @return void - */ - public function registerResources() - { - if ($this->isLumen() === false) { - $this->publishes([ - __DIR__ . '/../config/currency.php' => config_path('currency.php'), - ], 'config'); - - $this->mergeConfigFrom( - __DIR__ . '/../config/currency.php', 'currency' - ); - } - - $this->publishes([ - __DIR__ . '/../database/migrations' => base_path('/database/migrations'), - ], 'migrations'); - } - - /** - * Register currency commands. - * - * @return void - */ - public function registerCurrencyCommands() - { - $this->commands([ - Console\Cleanup::class, - Console\Manage::class, - Console\Update::class, - ]); - } - - /** - * Check if package is running under Lumen app - * - * @return bool - */ - protected function isLumen() - { - return Str::contains($this->app->version(), 'Lumen') === true; - } -} +registerCurrency(); + + if ($this->app->runningInConsole()) { + $this->registerResources(); + $this->registerCurrencyCommands(); + } + } + + /** + * Register currency provider. + * + * @return void + */ + public function registerCurrency() + { + $this->app->singleton('currency', function ($app) { + return new Currency( + $app->config->get('currency', []), + $app['cache'] + ); + }); + } + + /** + * Register currency resources. + * + * @return void + */ + public function registerResources() + { + if ($this->isLumen() === false) { + $this->publishes([ + __DIR__ . '/../config/currency.php' => config_path('currency.php'), + ], 'config'); + + $this->mergeConfigFrom( + __DIR__ . '/../config/currency.php', 'currency' + ); + } + + $this->publishes([ + __DIR__ . '/../database/migrations' => base_path('/database/migrations'), + ], 'migrations'); + } + + /** + * Register currency commands. + * + * @return void + */ + public function registerCurrencyCommands() + { + $this->commands([ + Console\Cleanup::class, + Console\Manage::class, + Console\Update::class, + ]); + } + + /** + * Check if package is running under Lumen app + * + * @return bool + */ + protected function isLumen() + { + return Str::contains($this->app->version(), 'Lumen') === true; + } +}