Browse Source

Add code style checks.

master
Lio Novelli 1 year ago
parent
commit
0346b9f29d
  1. 3
      .gitignore
  2. 9
      app/composer.json
  3. 1978
      app/composer.lock
  4. 20
      app/phpcs.xml
  5. 5
      app/src/Commands/RprtCommand.php
  6. 1
      app/src/Utils/Configuration/ConfigurationService.php

3
.gitignore

@ -1,3 +1,4 @@
/app/vendor
/resources/data
/scratch
/scratch
.phpcs-cache

9
app/composer.json

@ -25,5 +25,14 @@
"psr-4": {
"RprtCli\\": "src"
}
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9.5",
"opsway/psr12-strict-coding-standard": "^0.5.0"
},
"scripts": {
"cs": "phpcs",
"cbf": "phpcbf"
}
}

1978
app/composer.lock
File diff suppressed because it is too large
View File

20
app/phpcs.xml

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/>
<!-- Show progress -->
<arg value="p"/>
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<!-- Include all rules from the Zend Coding Standard -->
<rule ref="OpsWayStrictPSR12CodingStandard"/>
</ruleset>

5
app/src/Commands/RprtCommand.php

@ -48,14 +48,17 @@ class RprtCommand extends Command {
return Command::SUCCESS;
}
/**
* Create table from data that is already inline with configuration.
*/
protected function generateTable($output, $data) {
$table = new Table($output);
$table->setHeaders(['Project', 'Hours', 'Rate', 'Price']);
list($rows, $total_hours, $total_price) = [[], 0, 0];
$projects_config = $this->configuration->get('projects');
var_dump($projects_config);
foreach ($projects_config as $name => $config) {
if (!isset($data[$name])) {
// @TODO Proper error handling.
var_dump('Project ' . $name . ' is not set!');
continue;
}

1
app/src/Utils/Configuration/ConfigurationService.php

@ -77,7 +77,6 @@ class ConfigurationService implements ConfigurationInterface
*/
public function getConfig() {
if ($this->configFilePath) {
var_dump($this->configFilePath);
$config = Yaml::parseFile($this->configFilePath);
$this->data = $config;
return TRUE;

Loading…
Cancel
Save