diff --git a/composer.json b/composer.json index 85bd866..73d55b5 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "adeattwood/yii-addon", - "description": "Add-on for the yii2 framework", + "description": "Add on for the yii2 framework", "version": "1.0.1", "time": "2017-06-24 16:25:17", "type": "library", @@ -29,6 +29,7 @@ "require-dev": { "codeception/specify": "^0.4.6", "codeception/verify": "^0.3.3", - "codeception/codeception": "^2.3" + "codeception/codeception": "^2.3", + "squizlabs/php_codesniffer": "^2.8" } } \ No newline at end of file diff --git a/composer.lock b/composer.lock index 336976a..c69a451 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4a60d8b60f36b09a2233362c19a305ff", + "content-hash": "76e4b9dfeef71fc131683537fc22166b", "packages": [ { "name": "bower-asset/jquery", @@ -39,16 +39,16 @@ }, { "name": "bower-asset/jquery.inputmask", - "version": "3.3.7", + "version": "3.3.8", "source": { "type": "git", "url": "https://github.com/RobinHerbots/Inputmask.git", - "reference": "9835731cb78cac749734d94a1cb5bd70da4d3b10" + "reference": "791d84990c4a98df1597e9d155be53a3725805dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/RobinHerbots/Inputmask/zipball/9835731cb78cac749734d94a1cb5bd70da4d3b10", - "reference": "9835731cb78cac749734d94a1cb5bd70da4d3b10", + "url": "https://api.github.com/repos/RobinHerbots/Inputmask/zipball/791d84990c4a98df1597e9d155be53a3725805dd", + "reference": "791d84990c4a98df1597e9d155be53a3725805dd", "shasum": "" }, "require": { @@ -160,16 +160,16 @@ }, { "name": "cebe/markdown", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/cebe/markdown.git", - "reference": "c30eb5e01fe021cc5bba2f9ee0eeef96d4931166" + "reference": "25b28bae8a6f185b5030673af77b32e1163d5c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cebe/markdown/zipball/c30eb5e01fe021cc5bba2f9ee0eeef96d4931166", - "reference": "c30eb5e01fe021cc5bba2f9ee0eeef96d4931166", + "url": "https://api.github.com/repos/cebe/markdown/zipball/25b28bae8a6f185b5030673af77b32e1163d5c6e", + "reference": "25b28bae8a6f185b5030673af77b32e1163d5c6e", "shasum": "" }, "require": { @@ -216,7 +216,7 @@ "markdown", "markdown-extra" ], - "time": "2016-09-14T20:40:20+00:00" + "time": "2017-07-16T21:13:23+00:00" }, { "name": "ezyang/htmlpurifier", @@ -478,23 +478,23 @@ }, { "name": "codeception/codeception", - "version": "2.3.3", + "version": "2.3.5", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "67cd520b4f20cdfc3a52d1a0022924125822a8e6" + "reference": "e807cd458eb9f7ae7464f33ad835a2f54aa73194" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/67cd520b4f20cdfc3a52d1a0022924125822a8e6", - "reference": "67cd520b4f20cdfc3a52d1a0022924125822a8e6", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/e807cd458eb9f7ae7464f33ad835a2f54aa73194", + "reference": "e807cd458eb9f7ae7464f33ad835a2f54aa73194", "shasum": "" }, "require": { "behat/gherkin": "~4.4.0", "ext-json": "*", "ext-mbstring": "*", - "facebook/webdriver": ">=1.0.1 <2.0", + "facebook/webdriver": ">=1.1.3 <2.0", "guzzlehttp/guzzle": ">=4.1.4 <7.0", "guzzlehttp/psr7": "~1.0", "php": ">=5.4.0 <8.0", @@ -524,6 +524,7 @@ "php-amqplib/php-amqplib": "~2.4", "predis/predis": "^1.0", "squizlabs/php_codesniffer": "~2.0", + "symfony/process": ">=2.7 <4.0", "vlucas/phpdotenv": "^2.4.0" }, "suggest": { @@ -568,7 +569,7 @@ "functional testing", "unit testing" ], - "time": "2017-06-02T00:22:30+00:00" + "time": "2017-08-10T20:28:02+00:00" }, { "name": "codeception/specify", @@ -648,32 +649,32 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -698,7 +699,7 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "facebook/webdriver", @@ -1076,16 +1077,16 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -1126,26 +1127,26 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", + "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", "shasum": "" }, "require": { - "php": ">=5.5", + "php": "^7.0", "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { @@ -1171,24 +1172,24 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30T07:12:33+00:00" + "time": "2017-08-30T18:51:59+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.2.1", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { - "php": ">=5.5", + "php": "^5.5 || ^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { @@ -1218,26 +1219,26 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-11-25T06:54:22+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "v1.7.2", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", "sebastian/comparator": "^1.1|^2.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, @@ -1248,7 +1249,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -1281,32 +1282,32 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2017-09-04T11:05:03+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.2.1", + "version": "5.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "dc421f9ca5082a0c0cb04afb171c765f79add85b" + "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/dc421f9ca5082a0c0cb04afb171c765f79add85b", - "reference": "dc421f9ca5082a0c0cb04afb171c765f79add85b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b", + "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", "php": "^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", "phpunit/php-token-stream": "^1.4.11 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^3.0", - "sebastian/version": "^2.0", + "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { @@ -1314,7 +1315,7 @@ "phpunit/phpunit": "^6.0" }, "suggest": { - "ext-xdebug": "^2.5.3" + "ext-xdebug": "^2.5.5" }, "type": "library", "extra": { @@ -1345,7 +1346,7 @@ "testing", "xunit" ], - "time": "2017-04-21T08:03:57+00:00" + "time": "2017-08-03T12:40:43+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1486,29 +1487,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", + "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1531,20 +1532,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-08-20T05:47:52+00:00" }, { "name": "phpunit/phpunit", - "version": "6.2.2", + "version": "6.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e" + "reference": "ff3a76a58ac293657808aefd58c8aaf05945f4d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f2786490399836d2a544a34785c4a8d3ab32cf0e", - "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ff3a76a58ac293657808aefd58c8aaf05945f4d9", + "reference": "ff3a76a58ac293657808aefd58c8aaf05945f4d9", "shasum": "" }, "require": { @@ -1564,7 +1565,7 @@ "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "^4.0", "sebastian/comparator": "^2.0", - "sebastian/diff": "^1.4.3 || ^2.0", + "sebastian/diff": "^1.4.3", "sebastian/environment": "^3.0.2", "sebastian/exporter": "^3.1", "sebastian/global-state": "^1.1 || ^2.0", @@ -1615,26 +1616,26 @@ "testing", "xunit" ], - "time": "2017-06-13T14:07:07+00:00" + "time": "2017-08-03T13:59:28+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "4.0.1", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf" + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/eabce450df194817a7d7e27e19013569a903a2bf", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", + "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", + "doctrine/instantiator": "^1.0.5", "php": "^7.0", - "phpunit/php-text-template": "^1.2", + "phpunit/php-text-template": "^1.2.1", "sebastian/exporter": "^3.0" }, "conflict": { @@ -1674,7 +1675,7 @@ "mock", "xunit" ], - "time": "2017-03-03T06:30:20+00:00" + "time": "2017-08-03T14:08:16+00:00" }, { "name": "psr/http-message", @@ -1936,16 +1937,16 @@ }, { "name": "sebastian/environment", - "version": "3.0.4", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "74776f8dbc081cab9287c2a601c0c1d842568744" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/74776f8dbc081cab9287c2a601c0c1d842568744", - "reference": "74776f8dbc081cab9287c2a601c0c1d842568744", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { @@ -1957,7 +1958,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1982,7 +1983,7 @@ "environment", "hhvm" ], - "time": "2017-06-20T16:25:05+00:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", @@ -2104,21 +2105,21 @@ }, { "name": "sebastian/object-enumerator", - "version": "3.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "31dd3379d16446c5d86dec32ab1ad1f378581ad8" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/31dd3379d16446c5d86dec32ab1ad1f378581ad8", - "reference": "31dd3379d16446c5d86dec32ab1ad1f378581ad8", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { "php": "^7.0", - "sebastian/object-reflector": "^1.0", + "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, "require-dev": { @@ -2147,7 +2148,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-03-12T15:17:29+00:00" + "time": "2017-08-03T12:35:26+00:00" }, { "name": "sebastian/object-reflector", @@ -2332,6 +2333,84 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "2.9.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", + "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "bin": [ + "scripts/phpcs", + "scripts/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/Fixer.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2017-05-22T02:43:20+00:00" + }, { "name": "stecman/symfony-console-completion", "version": "0.7.0", @@ -2379,20 +2458,20 @@ }, { "name": "symfony/browser-kit", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1" + "reference": "aee7120b058c268363e606ff5fe8271da849a1b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1", - "reference": "c2c8ceb1aa9dab9eae54e9150e6a588ce3e53be1", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/aee7120b058c268363e606ff5fe8271da849a1b5", + "reference": "aee7120b058c268363e606ff5fe8271da849a1b5", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^5.5.9|>=7.0.8", "symfony/dom-crawler": "~2.8|~3.0" }, "require-dev": { @@ -2432,24 +2511,24 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2017-04-12T14:14:56+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "symfony/console", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e" + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/70d2a29b2911cbdc91a7e268046c395278238b2e", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e", + "url": "https://api.github.com/repos/symfony/console/zipball/a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", + "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^5.5.9|>=7.0.8", "symfony/debug": "~2.8|~3.0", "symfony/polyfill-mbstring": "~1.0" }, @@ -2462,7 +2541,6 @@ "symfony/dependency-injection": "~3.3", "symfony/event-dispatcher": "~2.8|~3.0", "symfony/filesystem": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0", "symfony/process": "~2.8|~3.0" }, "suggest": { @@ -2501,24 +2579,24 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-06-02T19:24:58+00:00" + "time": "2017-09-06T16:40:18+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "4d882dced7b995d5274293039370148e291808f2" + "reference": "c5f5263ed231f164c58368efbce959137c7d9488" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/4d882dced7b995d5274293039370148e291808f2", - "reference": "4d882dced7b995d5274293039370148e291808f2", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/c5f5263ed231f164c58368efbce959137c7d9488", + "reference": "c5f5263ed231f164c58368efbce959137c7d9488", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { @@ -2554,24 +2632,24 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2017-05-01T15:01:29+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "symfony/debug", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d" + "reference": "8beb24eec70b345c313640962df933499373a944" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/e9c50482841ef696e8fa1470d950a79c8921f45d", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d", + "url": "https://api.github.com/repos/symfony/debug/zipball/8beb24eec70b345c313640962df933499373a944", + "reference": "8beb24eec70b345c313640962df933499373a944", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^5.5.9|>=7.0.8", "psr/log": "~1.0" }, "conflict": { @@ -2610,24 +2688,24 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-06-01T21:01:25+00:00" + "time": "2017-09-01T13:23:39+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "fc2c588ce376e9fe04a7b8c79e3ec62fe32d95b1" + "reference": "6b511d7329b203a620f09a2288818d27dcc915ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/fc2c588ce376e9fe04a7b8c79e3ec62fe32d95b1", - "reference": "fc2c588ce376e9fe04a7b8c79e3ec62fe32d95b1", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/6b511d7329b203a620f09a2288818d27dcc915ae", + "reference": "6b511d7329b203a620f09a2288818d27dcc915ae", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^5.5.9|>=7.0.8", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -2666,24 +2744,24 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2017-05-25T23:10:31+00:00" + "time": "2017-09-11T15:55:22+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4054a102470665451108f9b59305c79176ef98f0" + "reference": "54ca9520a00386f83bca145819ad3b619aaa2485" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4054a102470665451108f9b59305c79176ef98f0", - "reference": "4054a102470665451108f9b59305c79176ef98f0", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/54ca9520a00386f83bca145819ad3b619aaa2485", + "reference": "54ca9520a00386f83bca145819ad3b619aaa2485", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" }, "conflict": { "symfony/dependency-injection": "<3.3" @@ -2729,24 +2807,24 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-06-04T18:15:29+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "symfony/finder", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4" + "reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/baea7f66d30854ad32988c11a09d7ffd485810c4", - "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4", + "url": "https://api.github.com/repos/symfony/finder/zipball/b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", + "reference": "b2260dbc80f3c4198f903215f91a1ac7fe9fe09e", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { @@ -2778,20 +2856,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-06-01T21:01:25+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f29dca382a6485c3cbe6379f0c61230167681937" + "reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", - "reference": "f29dca382a6485c3cbe6379f0c61230167681937", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803", + "reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803", "shasum": "" }, "require": { @@ -2803,7 +2881,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -2837,24 +2915,24 @@ "portable", "shim" ], - "time": "2017-06-09T14:24:12+00:00" + "time": "2017-06-14T15:44:48+00:00" }, { "name": "symfony/process", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8e30690c67aafb6c7992d6d8eb0d707807dd3eaf" + "reference": "b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8e30690c67aafb6c7992d6d8eb0d707807dd3eaf", - "reference": "8e30690c67aafb6c7992d6d8eb0d707807dd3eaf", + "url": "https://api.github.com/repos/symfony/process/zipball/b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0", + "reference": "b7666e9b438027a1ea0e1ee813ec5042d5d7f6f0", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { @@ -2886,24 +2964,24 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-05-22T12:32:03+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "symfony/yaml", - "version": "v3.3.2", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" + "reference": "1d8c2a99c80862bdc3af94c1781bf70f86bccac0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", + "url": "https://api.github.com/repos/symfony/yaml/zipball/1d8c2a99c80862bdc3af94c1781bf70f86bccac0", + "reference": "1d8c2a99c80862bdc3af94c1781bf70f86bccac0", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" }, "require-dev": { "symfony/console": "~2.8|~3.0" @@ -2941,7 +3019,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-06-02T22:05:06+00:00" + "time": "2017-07-29T21:54:42+00:00" }, { "name": "theseer/tokenizer", diff --git a/ruleset.xml b/ruleset.xml new file mode 100644 index 0000000..72a893d --- /dev/null +++ b/ruleset.xml @@ -0,0 +1,149 @@ + + + Yii addon coding standards + + ./src + + + + + + + + + + + */tests/* + */migrations/* + + + + */tests/* + */migrations/* + + + + warning + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + warning + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/behaviors/UploadedFileBehavior.php b/src/behaviors/UploadedFileBehavior.php index 4049a48..fa6b52e 100644 --- a/src/behaviors/UploadedFileBehavior.php +++ b/src/behaviors/UploadedFileBehavior.php @@ -5,11 +5,45 @@ namespace yiiaddon\behaviors; use yii\db\BaseActiveRecord; use yii\web\UploadedFile; +/** + * Loads the Uploaded file instance to an attribute in your model + * + * ~~~php + * use yiiaddon\behaviors\UploadedFileBehavior; + * + * public function behaviors() + * { + * return [ + * [ + * 'class' => UploadedFileBehavior::className(), + * 'fileAttribute' => 'my_file' + * ], + * ]; + * } + * ~~~ + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class UploadedFileBehavior extends \yii\behaviors\AttributeBehavior { + /** + * The attribute in your model that will be uploading the file from the form + * + * @var string + */ public $fileAttribute = 'file'; + /** + * The temporary instance of UploadFile + * + * @var yii\web\UploadedFile + */ public $value; /** @@ -25,6 +59,9 @@ class UploadedFileBehavior extends \yii\behaviors\AttributeBehavior } } + /** + * @inheritdoc + */ protected function getValue($event) { if ($this->value === null) { diff --git a/src/components/ActiveRecordCollection.php b/src/components/ActiveRecordCollection.php index 6ec53a5..e4a84e2 100644 --- a/src/components/ActiveRecordCollection.php +++ b/src/components/ActiveRecordCollection.php @@ -5,12 +5,36 @@ namespace yiiaddon\components; use yiiaddon\helpers\ArrayHelper; use yiiaddon\helpers\ArrayObject; +/** + * A collection of active records when getting data from the database + * + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class ActiveRecordCollection extends \yiiaddon\helpers\ArrayObject { + /** + * Maps a the collection into a single key-value pair + * + * ~~~php + * $model = Model::find()->all(); + * $map = $model->map('id', 'name'); + * ~~~ + * + * @param string $key The attribute you want to be the key + * @param string $value The attribute you want to be the value + * + * @return ArrayObject + */ public function map($key, $value) { - return new ArrayObject(ArrayHelper::map($this, $key, $value)); + return new ArrayObject(ArrayHelper::map((array)$this, $key, $value)); } -} \ No newline at end of file +} diff --git a/src/db/ActiveQuery.php b/src/db/ActiveQuery.php index 83d449c..6fb466d 100644 --- a/src/db/ActiveQuery.php +++ b/src/db/ActiveQuery.php @@ -4,12 +4,28 @@ namespace yiiaddon\db; use yiiaddon\components\ActiveRecordCollection; +/** + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class ActiveQuery extends \yii\db\ActiveQuery { + /** + * Overrides the Yii method to return an ActiveRecordCollection instead of an array + * + * @param mixed $db + * + * @return ActiveRecordCollection + */ public function all($db = null) { return new ActiveRecordCollection(parent::all($db)); } -} \ No newline at end of file +} diff --git a/src/db/ActiveRecord.php b/src/db/ActiveRecord.php index dad78c4..c279998 100644 --- a/src/db/ActiveRecord.php +++ b/src/db/ActiveRecord.php @@ -5,22 +5,56 @@ namespace yiiaddon\db; use Yii; use yiiaddon\helpers\ArrayHelper; +/** + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class ActiveRecord extends \yii\db\ActiveRecord { + /** + * Creates an instance of ActiveQuery + * + * @return yiiaddon\db\ActiveQuery + */ public static function find() { return Yii::createObject(ActiveQuery::className(), [get_called_class()]); } - public function parseAttribute($attribute, $defalts = [ 'format' => "text", 'value' => '( NOT SET )' ]) + /** + * Parses an attribute + * + * @see yiiaddon\helpers\ArrayHelper::parseAttribute + * + * @param string $attribute The attribute format string + * @param array $defalts The array of defalts to override + * + * @return yiiaddon\helpers\ArrayObject + */ + public function parseAttribute($attribute, $defalts = []) { return ArrayHelper::parseAttribute($this, $attribute, $defalts); } + /** + * Get a value of an attribute and formats with a string + * + * @see yiiaddon\helpers\ArrayHelper::parseAttribute + * + * @param string $attribute The attribute and format string + * @param string $defalt The defalt value to return if the attribute is not set + * + * @return mixed + */ public function getValue($attribute, $defalt = '( NOT SET )') { return $this->parseAttribute($attribute, ['value' => $defalt])->value; } -} \ No newline at end of file +} diff --git a/src/db/Rankable.php b/src/db/Rankable.php index ffaf500..628a50b 100644 --- a/src/db/Rankable.php +++ b/src/db/Rankable.php @@ -5,6 +5,15 @@ namespace yiiaddon\db; use Yii; use yii\db\Expression; +/** + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ trait Rankable { diff --git a/src/filters/PageMin.php b/src/filters/PageMin.php index 935d75d..5521fd3 100644 --- a/src/filters/PageMin.php +++ b/src/filters/PageMin.php @@ -6,10 +6,29 @@ use Yii; use yii\di\Instance; use yii\web\Response; +/** + * Minifies the html output of the page + * + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class PageMin extends \yii\base\ActionFilter { - public $enabled; + /** + * The the filter should be enabled + * + * @var boolean + */ + public $enabled = true; + /** + * @inheritDoc + */ public function beforeAction($action) { if (!$this->enabled) { @@ -21,11 +40,25 @@ class PageMin extends \yii\base\ActionFilter return true; } + /** + * Minifies the event data + * + * @param Event $event The request event + * + * @return void + */ public function pageMin($event) { Yii::$app->response->data = $this->minifyHtml($event->sender->data); } + /** + * Minifies html string + * + * @param string $input The string of html + * + * @return string The output html + */ public function minifyHtml( $input ) { if(trim($input) === "") return $input; @@ -76,6 +109,13 @@ class PageMin extends \yii\base\ActionFilter ); } + /** + * Minifies css strings inside the html + * + * @param string $input The input html + * + * @return string The output html + */ public function minifyCss($input) { if (trim($input) === '') { @@ -113,6 +153,13 @@ class PageMin extends \yii\base\ActionFilter ); } + /** + * Minifies js strings inside the html + * + * @param string $input The input html + * + * @return string The output html + */ public function minifyJs($input) { if (trim($input) === '') { diff --git a/src/helpers/ArrayHelper.php b/src/helpers/ArrayHelper.php index 6755a7b..d7c2a6d 100644 --- a/src/helpers/ArrayHelper.php +++ b/src/helpers/ArrayHelper.php @@ -10,8 +10,8 @@ use yiiaddon\helpers\Enum; /** * @category PHP - * @package adeattwood\yii-helpers - * @author Ade Attwood + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk @@ -64,7 +64,7 @@ class ArrayHelper extends \yii\helpers\ArrayHelper * * @return ArrayObject The parsed config */ - public static function parseAttribute( $model, $attribute, $defalts = [ 'format' => "text", 'value' => '( NOT SET )' ] ) + public static function parseAttribute( $model, $attribute, $defalts = [] ) { if ( !preg_match( '/^([^:]+)(:(\w*))?(:(.*))?$/', $attribute, $matches ) ) { throw new InvalidConfigException( 'The column must be specified in the format of "attribute", "attribute:format" or "attribute:format:label"' ); @@ -72,8 +72,8 @@ class ArrayHelper extends \yii\helpers\ArrayHelper $rawValue = self::getValue( $model, $matches[ 1 ] ); - $format = isset( $matches[ 3 ] ) ? $matches[ 3 ] : $defalts[ 'format' ]; - $value = Enum::isEmpty( $rawValue ) ? $defalts[ 'value' ] : Yii::$app->formatter->format( $rawValue, $format ); + $format = isset( $matches[ 3 ] ) ? $matches[ 3 ] : self::remove($defalts, 'format', 'text'); + $value = Enum::isEmpty( $rawValue ) ? self::remove($defalts, 'value', '( NOT SET )') : Yii::$app->formatter->format( $rawValue, $format ); $lable = isset( $matches[ 5 ] ) ? $matches[ 5 ] : $model->getAttributeLabel( $matches[ 1 ] ); return new ArrayObject( [ @@ -83,4 +83,5 @@ class ArrayHelper extends \yii\helpers\ArrayHelper 'raw' => $rawValue ] ); } + } diff --git a/src/helpers/ArrayObject.php b/src/helpers/ArrayObject.php index 308d72c..458d290 100644 --- a/src/helpers/ArrayObject.php +++ b/src/helpers/ArrayObject.php @@ -9,8 +9,8 @@ use yiiaddon\helpers\Enum; /** * @category PHP - * @package adeattwood\yii-helpers - * @author Ade Attwood + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk @@ -18,6 +18,7 @@ use yiiaddon\helpers\Enum; */ class ArrayObject extends \ArrayObject { + /** * __construct * @@ -54,7 +55,7 @@ class ArrayObject extends \ArrayObject * * @param int $count How many items to return * - * @return int|array + * @return int|self */ public function randomValue( $count = 1 ) { @@ -66,7 +67,99 @@ class ArrayObject extends \ArrayObject for ( $i = 0; $i < $count; $i++ ) { $r[] = $arr[$i]; } - return $count == 1 ? $r[0] : $r; + return $count == 1 ? $r[0] : new self($r); + } + + /** + * Adds an item to the start of the object + * + * @param mixed $value The item to prepend + * + * @return void + */ + public function prepend($value) + { + $array = $this->getArrayCopy(); + + if (is_string($value)) { + $value = (array)$value; + } + + if (is_object($value)) { + $value = [$value]; + } + $this->exchangeArray($value + $array); + } + + /** + * Combines an array to the existing object + * + * @param array $array The array to comnine + * + * @return void + */ + public function combine($array) + { + $this->exchangeArray(array_merge((array)$this->getArrayCopy(), $array)); + } + + /** + * Splits the object up into chunks + * + * Example: + * + * ~~~php + * $obj = new ArrayObject([ + * 'key_one' => 'Value One' + * 'key_two' => 'Value Two' + * 'key_three' => 'Value Three' + * 'key_four' => 'Value Four' + * 'key_five' => 'Value Five' + * 'key_six' => 'Value Six' + * ]); + * + * $chunks = $obj->chunks(2); + * + * [ + * [ + * 'key_one' => 'Value One' + * 'key_two' => 'Value Two' + * ], + * [ + * 'key_three' => 'Value Three' + * 'key_four' => 'Value Four' + * ], + * [ + * 'key_five' => 'Value Five' + * 'key_six' => 'Value Six' + * ], + * ] + * ~~~ + * + * @param integer $count How big to make the chunks + * + * @return void + */ + public function chunks($count) + { + $out = []; + $array = array_chunk((array)$this, $count); + + foreach ($array as $chunk) { + $out[] = new self($chunk); + } + + return new self($out); + } + + /** + * Turns the object into a json stirng + * + * @return string + */ + public function toJson() + { + return \yii\helpers\Json::encode((array)$this); } /** diff --git a/src/helpers/Dumper.php b/src/helpers/Dumper.php index 1b56140..39f4f87 100644 --- a/src/helpers/Dumper.php +++ b/src/helpers/Dumper.php @@ -1,11 +1,5 @@ + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk @@ -48,25 +48,38 @@ class Enum extends \yii\base\Object */ public static function getType( $var ) { - switch( $var ) { - case is_null( $var ): - return self::TYPE_NULL; - case is_array( $var ): - return self::TYPE_ARRAY; - case is_bool( $var ): - return self::TYPE_BOOL; - case is_float( $var ): - case is_numeric( str_replace( ',', '', $var ) ) && strpos( $var, '.' ) > 0 && is_float( ( float )str_replace( ',', '', $var ) ): - return self::TYPE_FLOAT; - case is_int( $var ) || ( is_numeric( $var ) && is_int( ( int )$var ) ): - return self::TYPE_INT; - case is_scalar( $var ) && strtotime( $var ) !== false: - return self::TYPE_DATETIME; - case is_scalar( $var ): - return self::TYPE_STRING; - default: - return self::TYPE_UNKNOWN; + if (is_null($var)) { + return self::TYPE_NULL; } + + if (is_array( $var )) { + return self::TYPE_ARRAY; + } + + if (is_bool( $var )) { + return self::TYPE_BOOL; + } + + if (is_float( $var ) + || (!is_object($var) && + is_numeric( str_replace( ',', '', $var ) ) && strpos( $var, '.' ) > 0 && is_float( ( float )str_replace( ',', '', $var ) )) + ) { + return self::TYPE_FLOAT; + } + + if (is_int( $var ) || ( is_numeric( $var ) && is_int( ( int )$var ) )) { + return self::TYPE_INT; + } + + if (is_scalar( $var ) && strtotime( $var ) !== false) { + return self::TYPE_DATETIME; + } + + if (is_scalar( $var )) { + return self::TYPE_STRING; + } + + return self::TYPE_UNKNOWN; } /** diff --git a/src/web/RedirectRule.php b/src/web/RedirectRule.php index f8f81ab..d626332 100644 --- a/src/web/RedirectRule.php +++ b/src/web/RedirectRule.php @@ -20,6 +20,14 @@ use yii\helpers\Url; * 'under-construction-about', * ] * ] + * + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 */ class RedirectRule extends \yii\web\UrlRule { diff --git a/src/web/View.php b/src/web/View.php index 1ec42ea..807d3d8 100644 --- a/src/web/View.php +++ b/src/web/View.php @@ -5,30 +5,135 @@ namespace yiiaddon\web; use Yii; use yii\helpers\Url; +/** + * @category PHP + * @package adeattwood\yii-addon + * @author Ade Attwood + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v1.2 + */ class View extends \yii\web\View { - public $facebook_og = true; + /** + * If to add facebook og tags to the head + * + * @var boolean + */ + public $facebook_og = true; + + /** + * If to add twitter cards to the head tag + * + * @var boolean + */ public $twitter_card = true; + /** + * Description of the page + * + * @var string + */ public $description; + + /** + * The url of the page + * + * This will be used in the canonical tag + * + * @var string + */ public $url; + + /** + * Keyword to be put in the kewords meata tag + * + * @var string + */ public $keywords; + + /** + * Url to the image to be used in the og and card metas + * + * @var string + */ public $image; + /** + * The twitter name e.g. '@twitter' + * + * @var string + */ public $twitterTag; + /** + * The page authers name + * + * @var string + */ public $authorName; + + /** + * The page authers twitter tag + * + * @var string + */ public $authorTwitterTag; + /** + * The default viewport content used in the viewport meta tag + * + * @var string + */ public $viewportContent = 'width=device-width, initial-scale=1'; + /** + * Googel analytics code to put in the js + * + * @var string + */ public $googleAnalyticsCode; + + /** + * The position to put the google analytics js + * + * Default is `POS_END` + * + * @var integer + */ public $googleAnalyticsPosition; + + /** + * The url to the google analytics js + * + * @var string + */ public $googleAnalyticsFile = 'https://www.google-analytics.com/analytics.js'; + + /** + * The js variable the store the google analytics js object in + * + * e.g. `ga('send', 'pageview');` + * + * @var string + */ public $googleAnalyticsVar = 'ga'; + /** + * Google analytics vars to set + * + * @var array + * + * @see https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference#set + */ protected $googleAnalyticsSet = []; + /** + * Initializes the view instance + * + * @return void + */ public function init() { if (!$this->googleAnalyticsPosition) { @@ -38,12 +143,26 @@ class View extends \yii\web\View return parent::init(); } + /** + * Adds a set variable to the google analyitcs script + * + * @see https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference#set + * + * @param string $key The var key + * @param mixed $value The var value + * + * @return void + */ public function googleAnalyticsSet($key, $value) { - $googleAnalyticsSet[$key] = $value; + $this->googleAnalyticsSet[$key] = $value; } - + /** + * Renders the head html adding all of the registers scripts and adding the meta tags + * + * @return string + */ public function renderHeadHtml() { $metas = [ @@ -86,6 +205,11 @@ class View extends \yii\web\View return '' . $this->title . '' . parent::renderHeadHtml(); } + /** + * Creates and registers the google analytics scripts + * + * @return void + */ public function registerGoogleAnalytics() { $js = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','$this->googleAnalyticsFile','$this->googleAnalyticsVar');"; @@ -97,9 +221,13 @@ class View extends \yii\web\View } $this->registerJS($js, $this->googleAnalyticsPosition); - } + /** + * Adds the facebook og meta tags + * + * @return array + */ public function registerFacebookOg() { return [ @@ -113,6 +241,11 @@ class View extends \yii\web\View ]; } + /** + * Adds the twitter card meta tags + * + * @return array + */ public function registerTwitterCard() { return [ diff --git a/tests/_data/ActiveModel.php b/tests/_data/ActiveModel.php new file mode 100644 index 0000000..5f5e47b --- /dev/null +++ b/tests/_data/ActiveModel.php @@ -0,0 +1,16 @@ + + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 95a09c9..0006d6a 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -3,8 +3,8 @@ namespace Helper; /** * @category PHP - * @package adeattwood\yii-helpers - * @author Ade Attwood + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php index ce6c790..a517cda 100644 --- a/tests/_support/UnitTester.php +++ b/tests/_support/UnitTester.php @@ -2,8 +2,8 @@ /** * @category PHP - * @package adeattwood\yii-helpers - * @author Ade Attwood + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index 5e94b4f..5473ecc 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -1,4 +1,4 @@ -getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a string doesn't start with the given prefix. + * + * @param string $prefix + * @param string $string + * @param string $message + * @see \Codeception\Module\Asserts::assertStringStartsNotWith() + */ + public function assertStringStartsNotWith($prefix, $string, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -402,6 +432,22 @@ trait UnitTesterActions } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that array contains subset. + * + * @param array $subset + * @param array $array + * @param bool $strict + * @param string $message + * @see \Codeception\Module\Asserts::assertArraySubset() + */ + public function assertArraySubset($subset, $array, $strict = null, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * diff --git a/tests/unit/ActiveRecordCest.php b/tests/unit/ActiveRecordCest.php new file mode 100644 index 0000000..c88a7fc --- /dev/null +++ b/tests/unit/ActiveRecordCest.php @@ -0,0 +1,58 @@ + + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v0.1 + */ +class ActiveRecordCest +{ + + public $model; + + public function _before( UnitTester $I ) + { + $this->model = new ActiveModel(['id' => 1]); + } + + public function _after( UnitTester $I ) + { + } + + public function testGetValue(UnitTester $I) + { + $value = $this->model->getValue('propOne'); + + $I->assertEquals($value, 'one'); + } + + public function testGetValueAsDate(UnitTester $I) + { + $value = $this->model->getValue('date:date'); + $I->assertEquals($value, 'Sep 17, 2017'); + } + + public function testParseAttribute(UnitTester $I) + { + $value = $this->model->parseAttribute('date:date'); + + $I->assertEquals($value->value, 'Sep 17, 2017'); + $I->assertEquals($value->raw, 1505655703); + $I->assertEquals($value->format, 'date'); + $I->assertEquals($value->lable, 'Date'); + } + + public function testFind(UnitTester $I) + { + $query = ActiveModel::find(); + $I->assertTrue($query instanceof ActiveQuery); + } + +} diff --git a/tests/unit/ActiveRecordCollectionCest.php b/tests/unit/ActiveRecordCollectionCest.php new file mode 100644 index 0000000..108bc55 --- /dev/null +++ b/tests/unit/ActiveRecordCollectionCest.php @@ -0,0 +1,45 @@ + + * @copyright 2017 adeattwood.co.uk + * @license BSD-2-Clause http://adeattwood.co.uk/license.html + * @link adeattwood.co.uk + * @since v0.1 + */ +class ActiveRecordCollectionCest +{ + + public $model; + + public function _before( UnitTester $I ) + { + $models = []; + + for ($i = 1; $i <= 10; $i++) { + $models[$i] = new ActiveModel(['id' => $i]); + } + + $this->model = new ActiveRecordCollection($models); + } + + public function _after( UnitTester $I ) + { + } + + public function testMap(UnitTester $I) + { + $maped = $this->model->map('id', 'propTwo'); + + $I->assertEquals($maped[1], 'two'); + $I->assertEquals($maped->count(), 10); + $I->assertTrue($maped instanceof ArrayObject); + } + +} diff --git a/tests/unit/ArrayHelperCest.php b/tests/unit/ArrayHelperCest.php index d93ef8b..d150a57 100644 --- a/tests/unit/ArrayHelperCest.php +++ b/tests/unit/ArrayHelperCest.php @@ -1,12 +1,12 @@ + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk diff --git a/tests/unit/ArrayObjectCest.php b/tests/unit/ArrayObjectCest.php index f6caa9a..7298e1b 100644 --- a/tests/unit/ArrayObjectCest.php +++ b/tests/unit/ArrayObjectCest.php @@ -1,11 +1,11 @@ + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk @@ -16,8 +16,8 @@ class ArrayObjectCest public $arrayObject; public $array = [ - "key_one" => "Value One", - "key_two" => "Value Two" + 'key_one' => 'Value One', + 'key_two' => 'Value Two' ]; public function _before( UnitTester $I ) @@ -62,7 +62,51 @@ class ArrayObjectCest { for( $i = 0; $i < 5; $i++ ) { $I->assertContains( $this->arrayObject->randomValue(), $this->array ); - // var_dump( $this->arrayObject->randomValue() ); } } + + public function testPrepend(UnitTester $I) + { + $this->arrayObject->prepend('New Value'); + + $I->assertEquals($this->arrayObject[0], 'New Value'); + + $this->arrayObject->prepend(['topProp' => 'Top Value']); + + $I->assertEquals($this->arrayObject->topProp, 'Top Value'); + } + + public function testToJson(UnitTester $I) + { + $json = $this->arrayObject->toJson(); + $I->assertEquals($json, '{"key_one":"Value One","key_two":"Value Two"}'); + } + + public function testChunk(UnitTester $I) + { + $this->arrayObject->combine([ + 'key_three' => 'Value Three', + 'key_four' => 'Value Four', + 'key_five' => 'Value Five', + 'key_six' => 'Value Six' + ]); + + $chunks = $this->arrayObject->chunks(2); + + $I->assertEquals($chunks->count(), 3); + + $I->assertEquals($chunks->{0}->count(), 2); + $I->assertEquals($chunks->{1}->count(), 2); + $I->assertEquals($chunks->{2}->count(), 2); + + $I->assertTrue($chunks->{0}->contains('Value One')); + $I->assertFalse($chunks->{0}->contains('Value Three')); + + $I->assertTrue($chunks->{1}->contains('Value Three')); + $I->assertFalse($chunks->{1}->contains('Value One')); + + $I->assertTrue($chunks->{2}->contains('Value Five')); + $I->assertFalse($chunks->{2}->contains('Value One')); + } + } diff --git a/tests/unit/EnumCest.php b/tests/unit/EnumCest.php index 8b4b465..7297bdf 100644 --- a/tests/unit/EnumCest.php +++ b/tests/unit/EnumCest.php @@ -1,11 +1,11 @@ + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk @@ -24,8 +24,8 @@ class EnumCest public function testNumberArray( UnitTester $I ) { - $I->assertEquals( Enum::formatBytes( 28434322.25 ), "27.12 MB" ); - $I->assertEquals( Enum::formatBytes( 17328347842.25, 3 ), "16.138 GB" ); + $I->assertEquals( Enum::formatBytes( 28434322.25 ), '27.12 MB' ); + $I->assertEquals( Enum::formatBytes( 17328347842.25, 3 ), '16.138 GB' ); } /** @@ -34,13 +34,14 @@ class EnumCest public function testGetTypeReturnValue( UnitTester $I ) { $array = [ - "array" => [ "key" => "value" ], - //"null" => null, - "boolean" => true, - "float" => 1.2, - "integer" => 3, - "datetime" => "2-2-1989", - "string" => "I'm a string" + 'array' => [ 'key' => 'value' ], + 'null' => null, + 'boolean' => true, + 'float' => 1.2, + 'integer' => 3, + 'datetime' => '2-2-1989', + 'string' => 'I\'m a string', + 'unknown' => new StdClass() ]; foreach ( $array as $type => $var ) { diff --git a/tests/unit/_bootstrap.php b/tests/unit/_bootstrap.php index 0362bc1..ab1cda6 100644 --- a/tests/unit/_bootstrap.php +++ b/tests/unit/_bootstrap.php @@ -2,8 +2,8 @@ /** * @category PHP - * @package adeattwood\yii-helpers - * @author Ade Attwood + * @package adeattwood\yii-addon + * @author Ade Attwood * @copyright 2017 adeattwood.co.uk * @license BSD-2-Clause http://adeattwood.co.uk/license.html * @link adeattwood.co.uk