Work on code style.
parent
99d16c3a72
commit
bbb22ab502
|
@ -30,14 +30,14 @@
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"squizlabs/php_codesniffer": "^3.7",
|
"squizlabs/php_codesniffer": "^3.7",
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
"opsway/psr12-strict-coding-standard": "^0.5.0",
|
"opsway/psr12-strict-coding-standard": "^1.0",
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
"phpstan/phpstan": "^1.9"
|
"phpstan/phpstan": "^1.9"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cs": "phpcs --colors --standard=PSR12",
|
"cs": "vendor/bin/phpcs --colors",
|
||||||
"cbf": "phpcbf",
|
"cbf": "vendor/bin/phpcbf",
|
||||||
"phpstan": "phpstan analyze -l 5 src"
|
"phpstan": "vendor/bin/phpstan analyze -l 5 src"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "eb0c874610e45fa74d8ccc691f5bd9f8",
|
"content-hash": "dcf2d10608163dc9004a26e38e06a533",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/lexer",
|
"name": "doctrine/lexer",
|
||||||
|
@ -2603,27 +2603,27 @@
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
||||||
"version": "v0.7.1",
|
"version": "v0.7.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
|
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
|
||||||
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
|
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
|
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||||
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
|
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"composer-plugin-api": "^1.0 || ^2.0",
|
"composer-plugin-api": "^1.0 || ^2.0",
|
||||||
"php": ">=5.3",
|
"php": ">=5.3",
|
||||||
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
|
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"composer/composer": "*",
|
"composer/composer": "*",
|
||||||
"phpcompatibility/php-compatibility": "^9.0",
|
"php-parallel-lint/php-parallel-lint": "^1.3.1",
|
||||||
"sensiolabs/security-checker": "^4.1.0"
|
"phpcompatibility/php-compatibility": "^9.0"
|
||||||
},
|
},
|
||||||
"type": "composer-plugin",
|
"type": "composer-plugin",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -2644,6 +2644,10 @@
|
||||||
"email": "franck.nijhof@dealerdirect.com",
|
"email": "franck.nijhof@dealerdirect.com",
|
||||||
"homepage": "http://www.frenck.nl",
|
"homepage": "http://www.frenck.nl",
|
||||||
"role": "Developer / IT Manager"
|
"role": "Developer / IT Manager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Contributors",
|
||||||
|
"homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
||||||
|
@ -2655,6 +2659,7 @@
|
||||||
"codesniffer",
|
"codesniffer",
|
||||||
"composer",
|
"composer",
|
||||||
"installer",
|
"installer",
|
||||||
|
"phpcbf",
|
||||||
"phpcs",
|
"phpcs",
|
||||||
"plugin",
|
"plugin",
|
||||||
"qa",
|
"qa",
|
||||||
|
@ -2665,7 +2670,11 @@
|
||||||
"stylecheck",
|
"stylecheck",
|
||||||
"tests"
|
"tests"
|
||||||
],
|
],
|
||||||
"time": "2020-12-07T18:04:37+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
|
||||||
|
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
|
||||||
|
},
|
||||||
|
"time": "2022-02-04T12:51:07+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/instantiator",
|
"name": "doctrine/instantiator",
|
||||||
|
@ -2795,30 +2804,29 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "opsway/psr12-strict-coding-standard",
|
"name": "opsway/psr12-strict-coding-standard",
|
||||||
"version": "0.5.0",
|
"version": "1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/opsway/psr12-strict-modern-standart.git",
|
"url": "https://github.com/opsway/psr12-strict-modern-standart.git",
|
||||||
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335"
|
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/495d5109079f544ec46ec2f0e2161d48f62a6335",
|
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
|
||||||
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335",
|
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "~0.6",
|
"dealerdirect/phpcodesniffer-composer-installer": "~0.7",
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^8.0",
|
||||||
"slevomat/coding-standard": "^6.1",
|
"slevomat/coding-standard": "^7.0 || ^8.0",
|
||||||
"squizlabs/php_codesniffer": "^3.5",
|
"squizlabs/php_codesniffer": "^3.6 || ^4.0",
|
||||||
"webimpress/coding-standard": "^1.1"
|
"webimpress/coding-standard": "^1.2"
|
||||||
},
|
},
|
||||||
"type": "phpcodesniffer-standard",
|
"type": "phpcodesniffer-standard",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.0.x-dev",
|
"dev-develop": "2.0.x-dev"
|
||||||
"dev-develop": "1.0.x-dev"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -2836,7 +2844,13 @@
|
||||||
"opsway",
|
"opsway",
|
||||||
"psr12-strict"
|
"psr12-strict"
|
||||||
],
|
],
|
||||||
"time": "2021-01-01T11:19:18+00:00"
|
"support": {
|
||||||
|
"docs": "https://github.com/opsway/psr12-strict-modern-standart/tree/master/docs",
|
||||||
|
"issues": "https://github.com/opsway/psr12-strict-modern-standart/issues",
|
||||||
|
"rss": "https://github.com/opsway/psr12-strict-modern-standart/releases.atom",
|
||||||
|
"source": "https://github.com/opsway/psr12-strict-modern-standart"
|
||||||
|
},
|
||||||
|
"time": "2022-10-22T12:21:38+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
|
@ -3240,39 +3254,31 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpdoc-parser",
|
"name": "phpstan/phpdoc-parser",
|
||||||
"version": "0.4.9",
|
"version": "1.15.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||||
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531"
|
"reference": "61800f71a5526081d1b5633766aa88341f1ade76"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531",
|
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/61800f71a5526081d1b5633766aa88341f1ade76",
|
||||||
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531",
|
"reference": "61800f71a5526081d1b5633766aa88341f1ade76",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1 || ^8.0"
|
"php": "^7.2 || ^8.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"consistence/coding-standard": "^3.5",
|
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||||
"ergebnis/composer-normalize": "^2.0.2",
|
|
||||||
"jakub-onderka/php-parallel-lint": "^0.9.2",
|
|
||||||
"phing/phing": "^2.16.0",
|
|
||||||
"phpstan/extension-installer": "^1.0",
|
"phpstan/extension-installer": "^1.0",
|
||||||
"phpstan/phpstan": "^0.12.26",
|
"phpstan/phpstan": "^1.5",
|
||||||
"phpstan/phpstan-strict-rules": "^0.12",
|
"phpstan/phpstan-phpunit": "^1.1",
|
||||||
"phpunit/phpunit": "^6.3",
|
"phpstan/phpstan-strict-rules": "^1.0",
|
||||||
"slevomat/coding-standard": "^4.7.2",
|
"phpunit/phpunit": "^9.5",
|
||||||
"symfony/process": "^4.0"
|
"symfony/process": "^5.2"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "0.4-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"PHPStan\\PhpDocParser\\": [
|
"PHPStan\\PhpDocParser\\": [
|
||||||
|
@ -3285,7 +3291,11 @@
|
||||||
"MIT"
|
"MIT"
|
||||||
],
|
],
|
||||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||||
"time": "2020-08-03T20:32:43+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||||
|
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.3"
|
||||||
|
},
|
||||||
|
"time": "2022-12-20T20:56:55+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
|
@ -4733,37 +4743,37 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "slevomat/coding-standard",
|
"name": "slevomat/coding-standard",
|
||||||
"version": "6.4.1",
|
"version": "8.7.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/slevomat/coding-standard.git",
|
"url": "https://github.com/slevomat/coding-standard.git",
|
||||||
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346"
|
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346",
|
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/c51edb898bebd36aac70a190c6a41a7c056bb5b9",
|
||||||
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346",
|
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
|
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
|
||||||
"php": "^7.1 || ^8.0",
|
"php": "^7.2 || ^8.0",
|
||||||
"phpstan/phpdoc-parser": "0.4.5 - 0.4.9",
|
"phpstan/phpdoc-parser": ">=1.15.0 <1.16.0",
|
||||||
"squizlabs/php_codesniffer": "^3.5.6"
|
"squizlabs/php_codesniffer": "^3.7.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phing/phing": "2.16.3",
|
"phing/phing": "2.17.4",
|
||||||
"php-parallel-lint/php-parallel-lint": "1.2.0",
|
"php-parallel-lint/php-parallel-lint": "1.3.2",
|
||||||
"phpstan/phpstan": "0.12.48",
|
"phpstan/phpstan": "1.4.10|1.9.3",
|
||||||
"phpstan/phpstan-deprecation-rules": "0.12.5",
|
"phpstan/phpstan-deprecation-rules": "1.1.0",
|
||||||
"phpstan/phpstan-phpunit": "0.12.16",
|
"phpstan/phpstan-phpunit": "1.0.0|1.3.1",
|
||||||
"phpstan/phpstan-strict-rules": "0.12.5",
|
"phpstan/phpstan-strict-rules": "1.4.4",
|
||||||
"phpunit/phpunit": "7.5.20|8.5.5|9.4.0"
|
"phpunit/phpunit": "7.5.20|8.5.21|9.5.27"
|
||||||
},
|
},
|
||||||
"type": "phpcodesniffer-standard",
|
"type": "phpcodesniffer-standard",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "6.x-dev"
|
"dev-master": "8.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -4776,7 +4786,25 @@
|
||||||
"MIT"
|
"MIT"
|
||||||
],
|
],
|
||||||
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
|
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
|
||||||
"time": "2020-10-05T12:39:37+00:00"
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"phpcs"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/slevomat/coding-standard/issues",
|
||||||
|
"source": "https://github.com/slevomat/coding-standard/tree/8.7.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/kukulich",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-12-14T08:49:18+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "squizlabs/php_codesniffer",
|
"name": "squizlabs/php_codesniffer",
|
||||||
|
@ -4886,24 +4914,24 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webimpress/coding-standard",
|
"name": "webimpress/coding-standard",
|
||||||
"version": "1.2.1",
|
"version": "1.2.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/webimpress/coding-standard.git",
|
"url": "https://github.com/webimpress/coding-standard.git",
|
||||||
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a"
|
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
|
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
|
||||||
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
|
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"squizlabs/php_codesniffer": "^3.5.8"
|
"squizlabs/php_codesniffer": "^3.6.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.4.3"
|
"phpunit/phpunit": "^9.5.13"
|
||||||
},
|
},
|
||||||
"type": "phpcodesniffer-standard",
|
"type": "phpcodesniffer-standard",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -4927,7 +4955,17 @@
|
||||||
"psr-12",
|
"psr-12",
|
||||||
"webimpress"
|
"webimpress"
|
||||||
],
|
],
|
||||||
"time": "2021-01-11T18:13:55+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/webimpress/coding-standard/issues",
|
||||||
|
"source": "https://github.com/webimpress/coding-standard/tree/1.2.4"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/michalbundyra",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-02-15T19:52:12+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webmozart/assert",
|
"name": "webmozart/assert",
|
||||||
|
|
|
@ -7,14 +7,18 @@
|
||||||
<arg name="colors"/>
|
<arg name="colors"/>
|
||||||
<arg name="extensions" value="php"/>
|
<arg name="extensions" value="php"/>
|
||||||
<arg name="parallel" value="10"/>
|
<arg name="parallel" value="10"/>
|
||||||
|
|
||||||
<!-- Show progress -->
|
<!-- Show progress -->
|
||||||
<arg value="p"/>
|
<arg value="p"/>
|
||||||
|
|
||||||
<!-- Paths to check -->
|
<!-- Paths to check -->
|
||||||
|
<file>tests</file>
|
||||||
<file>src</file>
|
<file>src</file>
|
||||||
<file>test</file>
|
|
||||||
|
|
||||||
<!-- Include all rules from the Zend Coding Standard -->
|
<!-- Include all rules from the Zend Coding Standard -->
|
||||||
<rule ref="OpsWayStrictPSR12CodingStandard"/>
|
<rule ref="OpsWayStrictPSR12CodingStandard">
|
||||||
|
<exclude name="Generic.NamingConventions.CamelCapsVariableName.Invalid" />
|
||||||
|
<exclude name="Squiz.NamingConventions.ValidVariableName" />
|
||||||
|
<exclude name="WebimpressCodingStandard.NamingConventions.ValidVariableName" />
|
||||||
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -27,10 +27,10 @@ use function explode;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
use function is_null;
|
use function is_null;
|
||||||
use function is_string;
|
use function is_string;
|
||||||
use function PHPUnit\Framework\throwException;
|
|
||||||
use function readline;
|
use function readline;
|
||||||
use function strpos;
|
use function strpos;
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
|
use function sys_get_temp_dir;
|
||||||
use function var_dump;
|
use function var_dump;
|
||||||
use function var_export;
|
use function var_export;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class InvoiceCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Get configuration.
|
* Get configuration.
|
||||||
*/
|
*/
|
||||||
protected function configure(): void
|
protected function configure() : void
|
||||||
{
|
{
|
||||||
$this->setName('invoice');
|
$this->setName('invoice');
|
||||||
$this->setDescription('Generate an invoice from (monthly) report');
|
$this->setDescription('Generate an invoice from (monthly) report');
|
||||||
|
@ -154,7 +154,7 @@ class InvoiceCommand extends Command
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||||
{
|
{
|
||||||
if ($input->getOption('test')) {
|
if ($input->getOption('test')) {
|
||||||
$test = $this->trackingService->testYoutrackapi();
|
$test = $this->trackingService->testYoutrackapi();
|
||||||
|
@ -205,7 +205,7 @@ class InvoiceCommand extends Command
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTable(OutputInterface $output, array $data): Table
|
protected function getTable(OutputInterface $output, array $data) : Table
|
||||||
{
|
{
|
||||||
$rows = $this->csv->generateTable($data);
|
$rows = $this->csv->generateTable($data);
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
|
@ -233,7 +233,7 @@ class InvoiceCommand extends Command
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* This method was almost exact copy of CsvReport::arangeDataForDefaultPdfExport
|
* This method was almost exact copy of CsvReport::arangeDataForDefaultPdfExport
|
||||||
*/
|
*/
|
||||||
protected function generateTable(OutputInterface $output, array $data): Table
|
protected function generateTable(OutputInterface $output, array $data) : Table
|
||||||
{
|
{
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
$table->setHeaders([
|
$table->setHeaders([
|
||||||
|
@ -276,7 +276,7 @@ class InvoiceCommand extends Command
|
||||||
$rows[] = new TableSeparator();
|
$rows[] = new TableSeparator();
|
||||||
// @TODO Check rate in final result.
|
// @TODO Check rate in final result.
|
||||||
// $rows[] = [$this->translator->trans('Sum'), $totalHours, $config['price'], $totalPrice];
|
// $rows[] = [$this->translator->trans('Sum'), $totalHours, $config['price'], $totalPrice];
|
||||||
$rows[] = ['Sum', $totalHours, NULL, $totalPrice];
|
$rows[] = ['Sum', $totalHours, null, $totalPrice];
|
||||||
|
|
||||||
$table->setRows($rows);
|
$table->setRows($rows);
|
||||||
return $table;
|
return $table;
|
||||||
|
@ -285,7 +285,7 @@ class InvoiceCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Dummy output for testing.
|
* Dummy output for testing.
|
||||||
*/
|
*/
|
||||||
protected function dummyOutput(InputInterface $input, OutputInterface $output): void
|
protected function dummyOutput(InputInterface $input, OutputInterface $output) : void
|
||||||
{
|
{
|
||||||
// $txt = $this->translator->trans('From [start-date] to [end-date].', [], 'rprt', 'sl_SI');
|
// $txt = $this->translator->trans('From [start-date] to [end-date].', [], 'rprt', 'sl_SI');
|
||||||
// $output->writeln($txt);
|
// $output->writeln($txt);
|
||||||
|
@ -345,9 +345,8 @@ class InvoiceCommand extends Command
|
||||||
} elseif ($type === self::TYPE_EXPENSE) {
|
} elseif ($type === self::TYPE_EXPENSE) {
|
||||||
$message_name = 'Enter expenses name or leave empty to stop: ';
|
$message_name = 'Enter expenses name or leave empty to stop: ';
|
||||||
$message_value = 'Enter expenses value: ';
|
$message_value = 'Enter expenses value: ';
|
||||||
}
|
} else {
|
||||||
else {
|
throw new Exception('Unknown type of custom data.');
|
||||||
throw new \Exception('Unknown type of custom data.');
|
|
||||||
}
|
}
|
||||||
while ($continue) {
|
while ($continue) {
|
||||||
$name = readline($message_name);
|
$name = readline($message_name);
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ReportCommand extends Command
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure() : void
|
||||||
{
|
{
|
||||||
$this->setName('report');
|
$this->setName('report');
|
||||||
$this->setDescription('Get a time-tracking report into command line.');
|
$this->setDescription('Get a time-tracking report into command line.');
|
||||||
|
@ -65,7 +65,7 @@ class ReportCommand extends Command
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output) : int
|
||||||
{
|
{
|
||||||
if ($timeRange = $input->getOption('time-range')) {
|
if ($timeRange = $input->getOption('time-range')) {
|
||||||
// @TODO: Implement time range option:
|
// @TODO: Implement time range option:
|
||||||
|
@ -95,7 +95,7 @@ class ReportCommand extends Command
|
||||||
*
|
*
|
||||||
* @TODO: Code duplication with InvoiceCommand::getTable.
|
* @TODO: Code duplication with InvoiceCommand::getTable.
|
||||||
*/
|
*/
|
||||||
protected function buildTable(OutputInterface $output, array $rows): Table
|
protected function buildTable(OutputInterface $output, array $rows) : Table
|
||||||
{
|
{
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
$table->setHeaders([
|
$table->setHeaders([
|
||||||
|
|
|
@ -71,7 +71,7 @@ trait SelectReportTrait
|
||||||
InputInterface $input,
|
InputInterface $input,
|
||||||
OutputInterface $output,
|
OutputInterface $output,
|
||||||
?string $default = 'tracking_service.youtrack.report.report'
|
?string $default = 'tracking_service.youtrack.report.report'
|
||||||
): ?string {
|
) : ?string {
|
||||||
if (! $file = $input->getOption('file')) {
|
if (! $file = $input->getOption('file')) {
|
||||||
$this->getReportParameter($input, $output, $default);
|
$this->getReportParameter($input, $output, $default);
|
||||||
$report_id = $this->trackingService->getReportId();
|
$report_id = $this->trackingService->getReportId();
|
||||||
|
|
|
@ -30,7 +30,7 @@ class TrackCommand extends Command
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure() : void
|
||||||
{
|
{
|
||||||
$this->setName('youtrack');
|
$this->setName('youtrack');
|
||||||
$this->setDescription('Track time into your youtrack service');
|
$this->setDescription('Track time into your youtrack service');
|
||||||
|
|
|
@ -11,7 +11,7 @@ interface ConfigurationInterface
|
||||||
/**
|
/**
|
||||||
* Get and read the configuration from file.
|
* Get and read the configuration from file.
|
||||||
*/
|
*/
|
||||||
public function getConfig(): bool;
|
public function getConfig() : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific configuration for key.
|
* Get a specific configuration for key.
|
||||||
|
@ -31,5 +31,5 @@ interface ConfigurationInterface
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* Key to check for.
|
* Key to check for.
|
||||||
*/
|
*/
|
||||||
public function exists($key): bool;
|
public function exists($key) : bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ConfigurationService implements ConfigurationInterface
|
||||||
/**
|
/**
|
||||||
* Get and read the configuration from file.
|
* Get and read the configuration from file.
|
||||||
*/
|
*/
|
||||||
public function getConfig(): bool
|
public function getConfig() : bool
|
||||||
{
|
{
|
||||||
if ($this->configFilePath) {
|
if ($this->configFilePath) {
|
||||||
$config = Yaml::parseFile($this->configFilePath);
|
$config = Yaml::parseFile($this->configFilePath);
|
||||||
|
@ -125,7 +125,7 @@ class ConfigurationService implements ConfigurationInterface
|
||||||
*
|
*
|
||||||
* Value of configuration key is not equal to default.
|
* Value of configuration key is not equal to default.
|
||||||
*/
|
*/
|
||||||
public function exists($key): bool
|
public function exists($key) : bool
|
||||||
{
|
{
|
||||||
return $this->get($key) !== $this->default;
|
return $this->get($key) !== $this->default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class CsvReport implements CsvReportInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getInvoiceData(string $filePath): array
|
public function getInvoiceData(string $filePath) : array
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
// @TODO replace with config service.
|
// @TODO replace with config service.
|
||||||
|
@ -69,7 +69,7 @@ class CsvReport implements CsvReportInterface
|
||||||
*
|
*
|
||||||
* Project key and unit of time spent.
|
* Project key and unit of time spent.
|
||||||
*/
|
*/
|
||||||
protected function parseCsvFile(array $rawData): array
|
protected function parseCsvFile(array $rawData) : array
|
||||||
{
|
{
|
||||||
$config = $this->configurationService->get('projects');
|
$config = $this->configurationService->get('projects');
|
||||||
foreach ($config as $key => $project) {
|
foreach ($config as $key => $project) {
|
||||||
|
@ -80,7 +80,7 @@ class CsvReport implements CsvReportInterface
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arangeDataForDefaultPdfExport(array $data): array
|
public function arangeDataForDefaultPdfExport(array $data) : array
|
||||||
{
|
{
|
||||||
[$rows, $totalHours, $totalPrice] = [[], 0, 0];
|
[$rows, $totalHours, $totalPrice] = [[], 0, 0];
|
||||||
$projectsConfig = $this->configurationService->get('projects');
|
$projectsConfig = $this->configurationService->get('projects');
|
||||||
|
@ -114,7 +114,7 @@ class CsvReport implements CsvReportInterface
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
'Gesamt netto',
|
'Gesamt netto',
|
||||||
number_format($totalHours, 2, ',', '.'),
|
number_format($totalHours, 2, ',', '.'),
|
||||||
NULL,
|
null,
|
||||||
number_format($totalPrice, 2, ',', '.'),
|
number_format($totalPrice, 2, ',', '.'),
|
||||||
];
|
];
|
||||||
$rows[] = [null, null, 'Gessamt brutto', number_format($totalPrice, 2, ',', '.')];
|
$rows[] = [null, null, 'Gessamt brutto', number_format($totalPrice, 2, ',', '.')];
|
||||||
|
@ -122,7 +122,7 @@ class CsvReport implements CsvReportInterface
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function dummyConfig(): array
|
protected function dummyConfig() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'projects' => [
|
'projects' => [
|
||||||
|
@ -132,7 +132,7 @@ class CsvReport implements CsvReportInterface
|
||||||
'price' => 26,
|
'price' => 26,
|
||||||
// optional specify columns
|
// optional specify columns
|
||||||
],
|
],
|
||||||
'TNP' => [
|
'TNP' => [
|
||||||
'name' => 'Triglav National Park',
|
'name' => 'Triglav National Park',
|
||||||
'pattern' => 'TNP-[0-9]+',
|
'pattern' => 'TNP-[0-9]+',
|
||||||
'price' => 26,
|
'price' => 26,
|
||||||
|
|
|
@ -19,7 +19,7 @@ interface CsvReportInterface
|
||||||
*
|
*
|
||||||
* Project key as key and number of hours as value.
|
* Project key as key and number of hours as value.
|
||||||
*/
|
*/
|
||||||
public function getInvoiceData(string $filePath): array;
|
public function getInvoiceData(string $filePath) : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data for default drunomics pdf export.
|
* Data for default drunomics pdf export.
|
||||||
|
@ -27,5 +27,5 @@ interface CsvReportInterface
|
||||||
*
|
*
|
||||||
* Parsed data from csv report.
|
* Parsed data from csv report.
|
||||||
*/
|
*/
|
||||||
public function arangeDataForDefaultPdfExport(array $data): array;
|
public function arangeDataForDefaultPdfExport(array $data) : array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ use function explode;
|
||||||
use function fgetcsv;
|
use function fgetcsv;
|
||||||
use function fopen;
|
use function fopen;
|
||||||
use function implode;
|
use function implode;
|
||||||
use function is_array;
|
|
||||||
use function is_numeric;
|
use function is_numeric;
|
||||||
use function number_format;
|
use function number_format;
|
||||||
use function preg_match;
|
use function preg_match;
|
||||||
|
@ -46,7 +45,7 @@ class ReportCsv implements ReportCsvInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getInvoiceData(string $filePath): array
|
public function getInvoiceData(string $filePath) : array
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
// @TODO replace with config service.
|
// @TODO replace with config service.
|
||||||
|
@ -80,7 +79,7 @@ class ReportCsv implements ReportCsvInterface
|
||||||
*
|
*
|
||||||
* Project key and unit of time spent.
|
* Project key and unit of time spent.
|
||||||
*/
|
*/
|
||||||
protected function parseCsvFile(array $rawData): array
|
protected function parseCsvFile(array $rawData) : array
|
||||||
{
|
{
|
||||||
$config = $this->configurationService->get('projects');
|
$config = $this->configurationService->get('projects');
|
||||||
foreach ($config as $key => $project) {
|
foreach ($config as $key => $project) {
|
||||||
|
@ -94,7 +93,7 @@ class ReportCsv implements ReportCsvInterface
|
||||||
/**
|
/**
|
||||||
* Input is array of Work elements and expenses.
|
* Input is array of Work elements and expenses.
|
||||||
*/
|
*/
|
||||||
public function generateTable(array $data): array
|
public function generateTable(array $data) : array
|
||||||
{
|
{
|
||||||
[$rows, $totalHours, $totalPrice, $add_separator] = [[], 0, 0, false];
|
[$rows, $totalHours, $totalPrice, $add_separator] = [[], 0, 0, false];
|
||||||
$projectsConfig = $this->configurationService->get('projects');
|
$projectsConfig = $this->configurationService->get('projects');
|
||||||
|
@ -126,12 +125,12 @@ class ReportCsv implements ReportCsvInterface
|
||||||
}
|
}
|
||||||
if ($add_separator) {
|
if ($add_separator) {
|
||||||
// @TODO replace separators with constants for normal separating.
|
// @TODO replace separators with constants for normal separating.
|
||||||
$rows[] = null;
|
$rows[] = null;
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
'Gesamt netto',
|
'Gesamt netto',
|
||||||
number_format($totalHours, 2, ',', '.'),
|
number_format($totalHours, 2, ',', '.'),
|
||||||
' ',
|
' ',
|
||||||
number_format($totalPrice, 2, ',', '.')
|
number_format($totalPrice, 2, ',', '.'),
|
||||||
];
|
];
|
||||||
$add_separator = false;
|
$add_separator = false;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +172,7 @@ class ReportCsv implements ReportCsvInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function arangeDataForDefaultPdfExport(array $data): array
|
public function arangeDataForDefaultPdfExport(array $data) : array
|
||||||
{
|
{
|
||||||
$rows = $this->generateTable($data);
|
$rows = $this->generateTable($data);
|
||||||
$header = $this->configurationService->get('export.labels', null);
|
$header = $this->configurationService->get('export.labels', null);
|
||||||
|
@ -189,20 +188,20 @@ class ReportCsv implements ReportCsvInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function generateReportTable(string $filePath): array
|
public function generateReportTable(string $filePath) : array
|
||||||
{
|
{
|
||||||
// ticket-id, ticket-name, time-spent
|
// ticket-id, ticket-name, time-spent
|
||||||
$data = $this->parseReportData($filePath);
|
$data = $this->parseReportData($filePath);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$explodeMinus = fn($ticket) => explode('-', $ticket)[0] ?? 'UNKNOWN';
|
$explodeMinus = fn($ticket) => explode('-', $ticket)[0] ?? 'UNKNOWN';
|
||||||
[$previous, $time_sum, $project_time, $table, $all_projects] = [
|
[$previous, $time_sum, $project_time, $table, $all_projects] = [
|
||||||
$data[0]['id'],
|
$data[0]['id'],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
[],
|
[],
|
||||||
[$explodeMinus($data[0]['id'])]
|
[$explodeMinus($data[0]['id'])],
|
||||||
];
|
];
|
||||||
foreach ($data as $line) {
|
foreach ($data as $line) {
|
||||||
$project = $explodeMinus($line['id']);
|
$project = $explodeMinus($line['id']);
|
||||||
|
@ -234,7 +233,7 @@ class ReportCsv implements ReportCsvInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function parseReportData(string $filePath): array
|
protected function parseReportData(string $filePath) : array
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
// @TODO replace with config service.
|
// @TODO replace with config service.
|
||||||
|
|
|
@ -32,14 +32,14 @@ interface ReportCsvInterface
|
||||||
*
|
*
|
||||||
* Project key as key and number of hours as value.
|
* Project key as key and number of hours as value.
|
||||||
*/
|
*/
|
||||||
public function getInvoiceData(string $filePath): array;
|
public function getInvoiceData(string $filePath) : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns array of rows created from array of InvoiceElements.
|
* Returns array of rows created from array of InvoiceElements.
|
||||||
*
|
*
|
||||||
* If row is null, it is meant to be a table separator.
|
* If row is null, it is meant to be a table separator.
|
||||||
*/
|
*/
|
||||||
public function generateTable(array $data): array;
|
public function generateTable(array $data) : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data for default drunomics pdf export.
|
* Data for default drunomics pdf export.
|
||||||
|
@ -47,7 +47,7 @@ interface ReportCsvInterface
|
||||||
*
|
*
|
||||||
* Parsed data from csv report.
|
* Parsed data from csv report.
|
||||||
*/
|
*/
|
||||||
public function arangeDataForDefaultPdfExport(array $data): array;
|
public function arangeDataForDefaultPdfExport(array $data) : array;
|
||||||
|
|
||||||
public function generateReportTable(string $filePath): array;
|
public function generateReportTable(string $filePath) : array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,17 @@ namespace RprtCli\Utils\Mailer;
|
||||||
/**
|
/**
|
||||||
* Methods for symfony (swift)mailer service.
|
* Methods for symfony (swift)mailer service.
|
||||||
*/
|
*/
|
||||||
interface MailerInterface {
|
interface MailerInterface
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Recipients for message.
|
* Recipients for message.
|
||||||
*
|
*
|
||||||
* @param string[] $to
|
* @param string[] $to
|
||||||
*/
|
*/
|
||||||
public function setRecipients(array $to): void;
|
public function setRecipients(array $to) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends default mail.
|
* Sends default mail.
|
||||||
*/
|
*/
|
||||||
public function sendDefaultMail(string $output): void;
|
public function sendDefaultMail(string $output) : void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,17 +54,17 @@ class MailerService implements MailerInterface
|
||||||
$this->pdf = $pdf;
|
$this->pdf = $pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRecipients(array $to): void
|
public function setRecipients(array $to) : void
|
||||||
{
|
{
|
||||||
$this->to = $to;
|
$this->to = $to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSubject(string $subject): void
|
public function setSubject(string $subject) : void
|
||||||
{
|
{
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAttachment(string $path): void
|
public function setAttachment(string $path) : void
|
||||||
{
|
{
|
||||||
// @TODO - add some error handling.
|
// @TODO - add some error handling.
|
||||||
$this->attachment = $path;
|
$this->attachment = $path;
|
||||||
|
@ -117,7 +117,7 @@ class MailerService implements MailerInterface
|
||||||
return $this->password;
|
return $this->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendMail(string $from, array $to, string $subject, string $text, array $attachment = []): void
|
public function sendMail(string $from, array $to, string $subject, string $text, array $attachment = []) : void
|
||||||
{
|
{
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
$email->from($from);
|
$email->from($from);
|
||||||
|
@ -155,7 +155,7 @@ class MailerService implements MailerInterface
|
||||||
return new Mailer($transport);
|
return new Mailer($transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendDefaultMail(string $output): void
|
public function sendDefaultMail(string $output) : void
|
||||||
{
|
{
|
||||||
$tokens = $this->pdf->gatherTokensForTemplate(
|
$tokens = $this->pdf->gatherTokensForTemplate(
|
||||||
$this->getEmailTemplatePath(),
|
$this->getEmailTemplatePath(),
|
||||||
|
@ -173,7 +173,7 @@ class MailerService implements MailerInterface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultTokens(): array
|
public function getDefaultTokens() : array
|
||||||
{
|
{
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
$date = strtotime('-1 month');
|
$date = strtotime('-1 month');
|
||||||
|
@ -182,7 +182,7 @@ class MailerService implements MailerInterface
|
||||||
return $tokens;
|
return $tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getEmailTemplatePath(): ?string
|
protected function getEmailTemplatePath() : ?string
|
||||||
{
|
{
|
||||||
if (! isset($this->templatePath)) {
|
if (! isset($this->templatePath)) {
|
||||||
$template_path = $this->config->get('email.template_path', false);
|
$template_path = $this->config->get('email.template_path', false);
|
||||||
|
@ -197,7 +197,7 @@ class MailerService implements MailerInterface
|
||||||
return $this->templatePath;
|
return $this->templatePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmailTemplatePath(string $path): void
|
public function setEmailTemplatePath(string $path) : void
|
||||||
{
|
{
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$this->templatePath = $path;
|
$this->templatePath = $path;
|
||||||
|
|
|
@ -13,9 +13,9 @@ interface PdfExportInterface
|
||||||
* Retrieves path to template file either from command option, configuration
|
* Retrieves path to template file either from command option, configuration
|
||||||
* or from uer input.
|
* or from uer input.
|
||||||
*/
|
*/
|
||||||
public function getTemplatePath(): ?string;
|
public function getTemplatePath() : ?string;
|
||||||
|
|
||||||
public function setTemplatePath(string $path): void;
|
public function setTemplatePath(string $path) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates html table from parsed csv data.
|
* Creates html table from parsed csv data.
|
||||||
|
@ -23,12 +23,12 @@ interface PdfExportInterface
|
||||||
*
|
*
|
||||||
* First line is header. The rest of them is table body.
|
* First line is header. The rest of them is table body.
|
||||||
*/
|
*/
|
||||||
public function parsedDataToHtmlTable(array $data): ?string;
|
public function parsedDataToHtmlTable(array $data) : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the template file and replaces token values.
|
* Reads the template file and replaces token values.
|
||||||
*/
|
*/
|
||||||
public function replaceTokensInTemplate(string $template_path, array $tokens): ?string;
|
public function replaceTokensInTemplate(string $template_path, array $tokens) : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and export file.
|
* Creates and export file.
|
||||||
|
@ -38,7 +38,7 @@ interface PdfExportInterface
|
||||||
*
|
*
|
||||||
* True if export was successfull.
|
* True if export was successfull.
|
||||||
*/
|
*/
|
||||||
public function pdfExport(string $html): bool;
|
public function pdfExport(string $html) : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Goes through the whole process of creating a pdf for the invoice.
|
* Goes through the whole process of creating a pdf for the invoice.
|
||||||
|
@ -48,7 +48,7 @@ interface PdfExportInterface
|
||||||
*
|
*
|
||||||
* Path of the pdf file.
|
* Path of the pdf file.
|
||||||
*/
|
*/
|
||||||
public function fromDefaultDataToPdf(array $nice_data, array $tokens = []): string;
|
public function fromDefaultDataToPdf(array $nice_data, array $tokens = []) : string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets output file override via command paramater.
|
* Sets output file override via command paramater.
|
||||||
|
@ -56,7 +56,7 @@ interface PdfExportInterface
|
||||||
*
|
*
|
||||||
* Path of the output pdf file ('/tmp/test.pdf').
|
* Path of the output pdf file ('/tmp/test.pdf').
|
||||||
*/
|
*/
|
||||||
public function setOutput(string $output): void;
|
public function setOutput(string $output) : void;
|
||||||
|
|
||||||
// @TODO support multiple templates by adding template id in config.
|
// @TODO support multiple templates by adding template id in config.
|
||||||
// @TODO implement twig.
|
// @TODO implement twig.
|
||||||
|
@ -80,5 +80,5 @@ interface PdfExportInterface
|
||||||
bool $skip_missing,
|
bool $skip_missing,
|
||||||
array $runtime_tokens = [],
|
array $runtime_tokens = [],
|
||||||
string $config = 'export.token'
|
string $config = 'export.token'
|
||||||
): array;
|
) : array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
$this->mpdf = $mpdf;
|
$this->mpdf = $mpdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplatePath(): ?string
|
public function getTemplatePath() : ?string
|
||||||
{
|
{
|
||||||
if (! isset($this->templatePath)) {
|
if (! isset($this->templatePath)) {
|
||||||
$template_path = $this->config->get('export.template_path', false);
|
$template_path = $this->config->get('export.template_path', false);
|
||||||
|
@ -50,7 +50,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
return $this->templatePath;
|
return $this->templatePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplatePath(string $path): void
|
public function setTemplatePath(string $path) : void
|
||||||
{
|
{
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$this->templatePath = $path;
|
$this->templatePath = $path;
|
||||||
|
@ -64,12 +64,12 @@ class PdfExportService implements PdfExportInterface
|
||||||
// @TODO would it make sense to allow more per user extending?
|
// @TODO would it make sense to allow more per user extending?
|
||||||
// @TODO - too much assumptions on data structure. Create a class with
|
// @TODO - too much assumptions on data structure. Create a class with
|
||||||
// precise data structure and use that to pass the data around.
|
// precise data structure and use that to pass the data around.
|
||||||
public function parsedDataToHtmlTable(array $data): ?string
|
public function parsedDataToHtmlTable(array $data) : ?string
|
||||||
{
|
{
|
||||||
$table = '<table><thead><tr class="tr-header">';
|
$table = '<table><thead><tr class="tr-header">';
|
||||||
$header = array_shift($data);
|
$header = array_shift($data);
|
||||||
$classes = '';
|
$classes = '';
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($header as $index => $cell) {
|
foreach ($header as $index => $cell) {
|
||||||
$table .= "<th class=\"th-{$index}\">{$cell}</th>";
|
$table .= "<th class=\"th-{$index}\">{$cell}</th>";
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replaceTokensInTemplate(string $template_path, array $tokens): ?string
|
public function replaceTokensInTemplate(string $template_path, array $tokens) : ?string
|
||||||
{
|
{
|
||||||
$template = file_get_contents($template_path);
|
$template = file_get_contents($template_path);
|
||||||
foreach ($tokens as $key => $value) {
|
foreach ($tokens as $key => $value) {
|
||||||
|
@ -116,7 +116,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO write a method to gather tokens.
|
// @TODO write a method to gather tokens.
|
||||||
public function getTokensInTemplate(string $template): array
|
public function getTokensInTemplate(string $template) : array
|
||||||
{
|
{
|
||||||
// @TODO find substrings of type [[key]]
|
// @TODO find substrings of type [[key]]
|
||||||
preg_match_all('/\[\[([a-z0-9-_]+)\]\]/', $template, $match);
|
preg_match_all('/\[\[([a-z0-9-_]+)\]\]/', $template, $match);
|
||||||
|
@ -144,7 +144,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
bool $skip_missing = false,
|
bool $skip_missing = false,
|
||||||
array $runtime_tokens = [],
|
array $runtime_tokens = [],
|
||||||
string $config = 'export.tokens'
|
string $config = 'export.tokens'
|
||||||
): array {
|
) : array {
|
||||||
[$tokens, $missing] = [[], []];
|
[$tokens, $missing] = [[], []];
|
||||||
$token_keys = $this->getTokensInTemplate(file_get_contents($template_path));
|
$token_keys = $this->getTokensInTemplate(file_get_contents($template_path));
|
||||||
$config_tokens = $this->config->get($config);
|
$config_tokens = $this->config->get($config);
|
||||||
|
@ -162,7 +162,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
return $tokens;
|
return $tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pdfExport(string $html, $output = null): bool
|
public function pdfExport(string $html, $output = null) : bool
|
||||||
{
|
{
|
||||||
$this->mpdf->SetProtection(['print']);
|
$this->mpdf->SetProtection(['print']);
|
||||||
// @TODO make configurable.
|
// @TODO make configurable.
|
||||||
|
@ -187,12 +187,12 @@ class PdfExportService implements PdfExportInterface
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOutput(string $path): void
|
public function setOutput(string $path) : void
|
||||||
{
|
{
|
||||||
$this->output = $path;
|
$this->output = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fromDefaultDataToPdf(array $data, array $tokens = []): string
|
public function fromDefaultDataToPdf(array $data, array $tokens = []) : string
|
||||||
{
|
{
|
||||||
$template_path = $this->getTemplatePath();
|
$template_path = $this->getTemplatePath();
|
||||||
$tokens = $this->defaultTokens();
|
$tokens = $this->defaultTokens();
|
||||||
|
@ -209,7 +209,7 @@ class PdfExportService implements PdfExportInterface
|
||||||
/**
|
/**
|
||||||
* Get default tokens.
|
* Get default tokens.
|
||||||
*/
|
*/
|
||||||
protected function defaultTokens(): array
|
protected function defaultTokens() : array
|
||||||
{
|
{
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
$tokens['today'] = date('j. m. y');
|
$tokens['today'] = date('j. m. y');
|
||||||
|
|
|
@ -9,12 +9,12 @@ interface YoutrackInterface
|
||||||
/**
|
/**
|
||||||
* Check if client can sign into youtrack with provided token.
|
* Check if client can sign into youtrack with provided token.
|
||||||
*/
|
*/
|
||||||
public function testYoutrackapi(): ?string;
|
public function testYoutrackapi() : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of the report from configuration.
|
* Get the id of the report from configuration.
|
||||||
*/
|
*/
|
||||||
public function getReportId(): ?string;
|
public function getReportId() : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads report and returns file path.
|
* Downloads report and returns file path.
|
||||||
|
@ -25,7 +25,7 @@ interface YoutrackInterface
|
||||||
*
|
*
|
||||||
* If fetch was unsuccssefull return false, otherwise the file path.
|
* If fetch was unsuccssefull return false, otherwise the file path.
|
||||||
*/
|
*/
|
||||||
public function downloadReport(string $report_id): ?string;
|
public function downloadReport(string $report_id) : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of reports.
|
* Get a list of reports.
|
||||||
|
@ -33,16 +33,16 @@ interface YoutrackInterface
|
||||||
*
|
*
|
||||||
* Array of reports with ids as keys and names as values.
|
* Array of reports with ids as keys and names as values.
|
||||||
*/
|
*/
|
||||||
public function listReports(): array;
|
public function listReports() : array;
|
||||||
|
|
||||||
public function setReportId(string $report_id): void;
|
public function setReportId(string $report_id) : void;
|
||||||
|
|
||||||
public function setReportName(?string $report_name = null): void;
|
public function setReportName(?string $report_name = null) : void;
|
||||||
|
|
||||||
public function getReportName(): ?string;
|
public function getReportName() : ?string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears cache for youtrack report.
|
* Clears cache for youtrack report.
|
||||||
*/
|
*/
|
||||||
public function clearReportCache(string $report_id): int;
|
public function clearReportCache(string $report_id) : int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class YoutrackService implements YoutrackInterface
|
||||||
$this->httpClient = $http_client;
|
$this->httpClient = $http_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYoutrackapi(): ?string
|
public function testYoutrackapi() : ?string
|
||||||
{
|
{
|
||||||
// Get base url from config or add input.
|
// Get base url from config or add input.
|
||||||
// Get token or add input.
|
// Get token or add input.
|
||||||
|
@ -88,7 +88,7 @@ class YoutrackService implements YoutrackInterface
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReportId(): ?string
|
public function getReportId() : ?string
|
||||||
{
|
{
|
||||||
// --report option value should take precedence.
|
// --report option value should take precedence.
|
||||||
// @TODO error handling.
|
// @TODO error handling.
|
||||||
|
@ -102,12 +102,12 @@ class YoutrackService implements YoutrackInterface
|
||||||
return $yt_report_id;
|
return $yt_report_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setReportId(string $report_id): void
|
public function setReportId(string $report_id) : void
|
||||||
{
|
{
|
||||||
$this->report_id = $report_id;
|
$this->report_id = $report_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setReportName(?string $report_name = null): void
|
public function setReportName(?string $report_name = null) : void
|
||||||
{
|
{
|
||||||
if (! $report_name) {
|
if (! $report_name) {
|
||||||
$reports = $this->listReports();
|
$reports = $this->listReports();
|
||||||
|
@ -120,12 +120,12 @@ class YoutrackService implements YoutrackInterface
|
||||||
$this->reportName = $report_name;
|
$this->reportName = $report_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReportName(): ?string
|
public function getReportName() : ?string
|
||||||
{
|
{
|
||||||
return $this->reportName;
|
return $this->reportName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadReport(string $report_id): ?string
|
public function downloadReport(string $report_id) : ?string
|
||||||
{
|
{
|
||||||
$path = "youtrack/api/reports/$report_id/export/csv";
|
$path = "youtrack/api/reports/$report_id/export/csv";
|
||||||
$query = ['$top' => -1];
|
$query = ['$top' => -1];
|
||||||
|
@ -161,7 +161,7 @@ class YoutrackService implements YoutrackInterface
|
||||||
throw new Exception("Unable to download report {$report_id}!");
|
throw new Exception("Unable to download report {$report_id}!");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getYtToken(): string
|
protected function getYtToken() : string
|
||||||
{
|
{
|
||||||
if (isset($this->ytToken)) {
|
if (isset($this->ytToken)) {
|
||||||
return $this->ytToken;
|
return $this->ytToken;
|
||||||
|
@ -173,12 +173,12 @@ class YoutrackService implements YoutrackInterface
|
||||||
return $yt_token;
|
return $yt_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setYtToken(string $token): void
|
public function setYtToken(string $token) : void
|
||||||
{
|
{
|
||||||
$this->ytToken = $token;
|
$this->ytToken = $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getYtUrl(string $path = ''): ?string
|
protected function getYtUrl(string $path = '') : ?string
|
||||||
{
|
{
|
||||||
if (isset($this->ytBaseUrl)) {
|
if (isset($this->ytBaseUrl)) {
|
||||||
$yt_base_url = $this->ytBaseUrl;
|
$yt_base_url = $this->ytBaseUrl;
|
||||||
|
@ -199,7 +199,7 @@ class YoutrackService implements YoutrackInterface
|
||||||
$this->ytBaseUrl = $base_url;
|
$this->ytBaseUrl = $base_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listReports(): array
|
public function listReports() : array
|
||||||
{
|
{
|
||||||
// Now filter results by own = true;
|
// Now filter results by own = true;
|
||||||
$url = '/youtrack/api/reports';
|
$url = '/youtrack/api/reports';
|
||||||
|
@ -218,11 +218,11 @@ class YoutrackService implements YoutrackInterface
|
||||||
return $reports;
|
return $reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearReportCache(string $report_id): int
|
public function clearReportCache(string $report_id) : int
|
||||||
{
|
{
|
||||||
$path = "/youtrack/api/reports/${report_id}/status";
|
$path = "/youtrack/api/reports/${report_id}/status";
|
||||||
$query = [
|
$query = [
|
||||||
'$top' => -1,
|
'$top' => -1,
|
||||||
// phpcs:ignore
|
// phpcs:ignore
|
||||||
'fields' => 'calculationInProgress,error(id),errorMessage,isOutdated,lastCalculated,progress,wikifiedErrorMessage',
|
'fields' => 'calculationInProgress,error(id),errorMessage,isOutdated,lastCalculated,progress,wikifiedErrorMessage',
|
||||||
];
|
];
|
||||||
|
|
|
@ -4,12 +4,15 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace RprtCli\Tests\Kernel;
|
namespace RprtCli\Tests\Kernel;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Console\Application;
|
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use RprtCli\Commands\InvoiceCommand;
|
use RprtCli\Commands\InvoiceCommand;
|
||||||
use RprtCli\Commands\ReportCommand;
|
use RprtCli\Commands\ReportCommand;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
|
use function file_exists;
|
||||||
|
use function unlink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report and invoice command test.
|
* Report and invoice command test.
|
||||||
|
@ -17,8 +20,8 @@ use RprtCli\Commands\ReportCommand;
|
||||||
* Does not cover the part of talking to the api, nor does it yet cover email
|
* Does not cover the part of talking to the api, nor does it yet cover email
|
||||||
* and pdf generation. @TODO
|
* and pdf generation. @TODO
|
||||||
*/
|
*/
|
||||||
class ReportCommandTest extends TestCase {
|
class ReportCommandTest extends TestCase
|
||||||
|
{
|
||||||
protected const INPUT_CSV_FILE = __DIR__ . '/../data/21-03.csv';
|
protected const INPUT_CSV_FILE = __DIR__ . '/../data/21-03.csv';
|
||||||
|
|
||||||
protected const REPORT_OUTPUT_FILE = __DIR__ . '/../data/report-21-03.txt';
|
protected const REPORT_OUTPUT_FILE = __DIR__ . '/../data/report-21-03.txt';
|
||||||
|
@ -30,7 +33,8 @@ class ReportCommandTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Run report and invoice command with file option parameter. Check if pdf was generated.
|
* Run report and invoice command with file option parameter. Check if pdf was generated.
|
||||||
*/
|
*/
|
||||||
public function testExecute() {
|
public function testExecute()
|
||||||
|
{
|
||||||
$builder = new ContainerBuilder();
|
$builder = new ContainerBuilder();
|
||||||
$builder->addDefinitions(__DIR__ . '/../test-dependencies.php');
|
$builder->addDefinitions(__DIR__ . '/../test-dependencies.php');
|
||||||
$container = $builder->build();
|
$container = $builder->build();
|
||||||
|
@ -42,8 +46,7 @@ class ReportCommandTest extends TestCase {
|
||||||
$reportCommand = $container->get(ReportCommand::class);
|
$reportCommand = $container->get(ReportCommand::class);
|
||||||
$application->add($reportCommand);
|
$application->add($reportCommand);
|
||||||
|
|
||||||
|
$reportCommand = $application->find('report');
|
||||||
$reportCommand = $application->find('report');
|
|
||||||
$reportCommandTester = new CommandTester($reportCommand);
|
$reportCommandTester = new CommandTester($reportCommand);
|
||||||
$reportCommandTester->execute([
|
$reportCommandTester->execute([
|
||||||
// pass arguments to the helper
|
// pass arguments to the helper
|
||||||
|
@ -66,11 +69,11 @@ class ReportCommandTest extends TestCase {
|
||||||
if (file_exists(self::INVOICE_OUTPUT_PDF)) {
|
if (file_exists(self::INVOICE_OUTPUT_PDF)) {
|
||||||
unlink(self::INVOICE_OUTPUT_PDF);
|
unlink(self::INVOICE_OUTPUT_PDF);
|
||||||
}
|
}
|
||||||
$invoiceCommand = $application->find('invoice');
|
$invoiceCommand = $application->find('invoice');
|
||||||
$invoiceCommandTester = new CommandTester($invoiceCommand);
|
$invoiceCommandTester = new CommandTester($invoiceCommand);
|
||||||
$invoiceCommandTester->execute([
|
$invoiceCommandTester->execute([
|
||||||
'--file' => self::INPUT_CSV_FILE,
|
'--file' => self::INPUT_CSV_FILE,
|
||||||
'--pdf' => TRUE,
|
'--pdf' => true,
|
||||||
'--output' => self::INVOICE_OUTPUT_PDF,
|
'--output' => self::INVOICE_OUTPUT_PDF,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -83,5 +86,4 @@ class ReportCommandTest extends TestCase {
|
||||||
$this->assertStringEqualsFile(self::INVOICE_OUTPUT_FILE, $invoice_output);
|
$this->assertStringEqualsFile(self::INVOICE_OUTPUT_FILE, $invoice_output);
|
||||||
$this->assertFileExists(self::INVOICE_OUTPUT_PDF);
|
$this->assertFileExists(self::INVOICE_OUTPUT_PDF);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$dependencies = require_once(__DIR__ . '/../dependencies.php');
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$dependencies = require_once __DIR__ . '/../dependencies.php';
|
||||||
|
|
||||||
$dependencies['config.path'] = __DIR__ . '/data/';
|
$dependencies['config.path'] = __DIR__ . '/data/';
|
||||||
|
|
||||||
|
|
4
todo.txt
4
todo.txt
|
@ -12,13 +12,15 @@ TODO:
|
||||||
------------------------
|
------------------------
|
||||||
- phing for build automation
|
- phing for build automation
|
||||||
- add ddev for dockerization
|
- add ddev for dockerization
|
||||||
|
- invoice command improvements
|
||||||
|
- pdf and output option could be combined
|
||||||
|
|
||||||
TODO (end of 2022):
|
TODO (end of 2022):
|
||||||
- DONE fix project list output (first is missing)
|
- DONE fix project list output (first is missing)
|
||||||
- DONE report selection trait
|
- DONE report selection trait
|
||||||
- DONE automated tests
|
- DONE automated tests
|
||||||
- DONE phpcs
|
- DONE phpcs
|
||||||
- phpstan
|
- DONE phpstan (level 5)
|
||||||
OPTIONAL:
|
OPTIONAL:
|
||||||
- phing build system to run quality assurance
|
- phing build system to run quality assurance
|
||||||
- DONE fix -y parameter in invoice
|
- DONE fix -y parameter in invoice
|
||||||
|
|
Loading…
Reference in New Issue