Compare commits

...

2 Commits

Author SHA1 Message Date
45ea239d7c Perform analysis 2023-06-01 09:22:23 +00:00
c3ef0400f6 PHP_CodeSniffer performed. 2023-06-01 09:16:19 +00:00
6 changed files with 25 additions and 8 deletions

@ -11,4 +11,12 @@ pipeline:
image: composer image: composer
commands: commands:
- composer install - composer install
- ./vendor/bin/phpunit tests - ./vendor/bin/phpunit tests
analyze:
image: php
commands:
- ./vendor/bin/phpmd src text cleancode,codesize,controversial,design,naming,unusedcode
- ./vendor/bin/phpstan analyze --level=7 src/ backup
- ./vendor/bin/psalm
- ./vendor/bin/phpcs src
failure: ignore

@ -5,6 +5,8 @@ analyze-all:
-./vendor/bin/phpstan analyze --level=7 src/ backup -./vendor/bin/phpstan analyze --level=7 src/ backup
@echo Psalm @echo Psalm
-./vendor/bin/psalm -./vendor/bin/psalm
@echo PHP_CodeSniffer
-./vendor/bin/phpcs src
install: install:
php composer.phar install --no-dev php composer.phar install --no-dev
install-dev: install-dev:

@ -8,7 +8,8 @@ use Monolog\Logger;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
class App { class App
{
protected Logger $logger; protected Logger $logger;
protected array $config; protected array $config;
@ -16,7 +17,7 @@ class App {
{ {
$this->config = Yaml::parseFile($configFile); $this->config = Yaml::parseFile($configFile);
$logger = new Logger('app'); $logger = new Logger('app');
if(isset($this->config['log'])) { if (isset($this->config['log'])) {
$logger->pushHandler(new StreamHandler($this->getConfig()['log'])); $logger->pushHandler(new StreamHandler($this->getConfig()['log']));
} }
$logger->info("Initialization complete"); $logger->info("Initialization complete");

@ -41,7 +41,7 @@ class CommandBackup extends Command
$rclone->setLogger($app->getLogger()->withName('rclone')); $rclone->setLogger($app->getLogger()->withName('rclone'));
$ntfy = new Ntfy\Ntfy($app->getConfig()['notification']['domain']); $ntfy = new Ntfy\Ntfy($app->getConfig()['notification']['domain']);
$ntfy->setLogger( $app->getLogger()->withName('notification')); $ntfy->setLogger($app->getLogger()->withName('notification'));
$loader = new ArrayLoader($app->getConfig()['templates']); $loader = new ArrayLoader($app->getConfig()['templates']);
$twig = new Environment($loader); $twig = new Environment($loader);

@ -10,7 +10,7 @@ use Symfony\Component\Process\Exception\ProcessFailedException;
use Exception; use Exception;
class Rclone class Rclone
{ {
use LoggerAwareTrait; use LoggerAwareTrait;
@ -70,8 +70,12 @@ class Rclone
} }
/** /**
* @param $command Top level Rclone command * Execute a command on the rclone binary
* @param array<String> $options *
* @param string $command Top level Rclone command
* @param array<String> $options Array of additional options
*
* @return string stdout data.
*/ */
protected function exec(string $command, array $options = array()) : string protected function exec(string $command, array $options = array()) : string
{ {

@ -17,8 +17,10 @@ class AppExtension extends AbstractExtension
/** /**
* Format a file size to be human readable * Format a file size to be human readable
*
* @param int $bytes Number of bytes * @param int $bytes Number of bytes
* @param int $precision Precision * @param int $precision Precision
*
* @return string Formatted string * @return string Formatted string
*/ */
public function formatBytes($bytes, $precision = 2) public function formatBytes($bytes, $precision = 2)