diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..23662dc --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,39 @@ +build: + tests: + override: + - php-scrutinizer-run +filter: + excluded_paths: [tests/*] +checks: + php: + code_rating: true + remove_extra_empty_lines: true + remove_php_closing_tag: true + remove_trailing_whitespace: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: true + order_alphabetically: true + fix_php_opening_tag: true + fix_linefeed: true + fix_line_ending: true + fix_identation_4spaces: true + fix_doc_comments: true +tools: + external_code_coverage: + timeout: 600 + runs: 3 + php_analyzer: true + php_code_coverage: false + php_code_sniffer: + config: + standard: PSR2 + filter: + paths: ['src'] + php_loc: + enabled: true + excluded_dirs: [vendor, tests] + php_cpd: + enabled: true + excluded_dirs: [vendor, tests] \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8b62755 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: php + +php: + - 5.6 + - 7.1 + - 7.2 + - 7.3 + - 7.4 + +install: + - composer self-update + - composer global require "fxp/composer-asset-plugin:~1.3" + - composer install + +before_script: + - travis_retry composer self-update && composer --version + - travis_retry composer install --no-interaction --prefer-source --dev + +script: + - composer info | sort + - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file diff --git a/README.md b/README.md index aa7b0f3..0939038 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ # Yii2 upload file behavior # +[![Software License](https://img.shields.io/github/license/coderius/yii2-upload-file-behavior)](LICENSE.md) +[![Latest Version](https://img.shields.io/github/tag/coderius/yii2-upload-file-behavior.svg?style=flat-square&label=release)](https://github.com/coderius/yii2-upload-file-behavior/tags) +[![Code Coverage](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/?branch=master) +[![Code Intelligence Status](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) +[![Code Quality](https://img.shields.io/scrutinizer/quality/g/coderius/yii2-upload-file-behavior.svg?style=flat-square)](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/?branch=master) +[![Build Status](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/badges/build.png?b=master)](https://scrutinizer-ci.com/g/coderius/yii2-upload-file-behavior/build-status/master) +[![Total Downloads](https://img.shields.io/packagist/dt/coderius/yii2-upload-file-behavior.svg?style=flat-square)](https://packagist.org/packages/coderius/yii2-upload-file-behavior) + ## About Yii2 upload file behavior - simple wey to upload images and files to server. diff --git a/composer.json b/composer.json index 7bdcdb6..2fe6407 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,12 @@ "github-no-api": true }, "asset-pattern-skip-version": "(-patch)" - } + }, + "repositories": [ + { + "type": "composer", + "url": "https://asset-packagist.org" + } + ] } diff --git a/src/UploadFileBehavior.php b/src/UploadFileBehavior.php index 029f41b..ee17632 100644 --- a/src/UploadFileBehavior.php +++ b/src/UploadFileBehavior.php @@ -110,7 +110,7 @@ class UploadFileBehavior extends Behavior /** * Name of attribute for recording file from form to ActiveRecord. DEfault name of attribute is `file` * - * @var [string] + * @var string */ public $nameOfAttributeFile = 'file'; @@ -122,7 +122,7 @@ class UploadFileBehavior extends Behavior /** * Image name for renaming file and in next saving in file system and db * - * @var [string] + * @var string */ public $newFileName = false; @@ -140,7 +140,7 @@ class UploadFileBehavior extends Behavior * } * ], * - * @var [array] + * @var array */ public $targets; @@ -168,7 +168,7 @@ class UploadFileBehavior extends Behavior /** * Undocumented variable * - * @var [boolean | int] + * @var boolean|int */ private $time = false; @@ -229,8 +229,7 @@ protected static function supportedFileTypes(){ /** * Undocumented function * - * @param [type] $event - * @return void + * @return void */ public function loadFile() { @@ -243,7 +242,6 @@ public function loadFile() /** * Undocumented function * - * @param [type] $event * @return void */ public function afterInsertHendler($event) @@ -254,7 +252,6 @@ public function afterInsertHendler($event) /** * Undocumented function * - * @param [type] $event * @return void */ public function afterUpdateHendler($event) @@ -265,7 +262,7 @@ public function afterUpdateHendler($event) /** * Undocumented function * - * @param [type] $event + * @param Event $event * @return void */ public function afterDelete($event) @@ -283,7 +280,7 @@ public function afterDelete($event) /** * Undocumented function * - * @param [type] $insert + * @param boolean $insert * @return void */ protected function hendlersReducer($insert) @@ -308,6 +305,10 @@ protected function hendlersReducer($insert) return false; } + /** + * @param string $path + * @return string $dirPath + */ protected function getPath($path){ if(is_string($path)){ $path = rtrim($path, '/') . '/'; diff --git a/tests/TestCase.php b/tests/TestCase.php index 1717510..f1c9f6b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,7 +13,7 @@ */ abstract class TestCase extends \PHPUnit\Framework\TestCase { - protected function setUp(): void + protected function setUp() { parent::setUp(); $this->mockWebApplication(); @@ -23,7 +23,7 @@ protected function setUp(): void * Clean up after test. * By default the application created with [[mockApplication]] will be destroyed. */ - protected function tearDown(): void + protected function tearDown() { parent::tearDown(); $this->destroyApplication();