diff --git a/composer.lock b/composer.lock index 54aea1e..6c6763d 100644 --- a/composer.lock +++ b/composer.lock @@ -3297,16 +3297,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.28", + "version": "1.10.29", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e4545b55904ebef470423d3ddddb74fa7325497a" + "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e4545b55904ebef470423d3ddddb74fa7325497a", - "reference": "e4545b55904ebef470423d3ddddb74fa7325497a", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", + "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", "shasum": "" }, "require": { @@ -3355,7 +3355,7 @@ "type": "tidelift" } ], - "time": "2023-08-08T12:33:42+00:00" + "time": "2023-08-14T13:24:11+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3679,16 +3679,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.3.1", + "version": "10.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d442ce7c4104d5683c12e67e4dcb5058159e9804" + "reference": "0dafb1175c366dd274eaa9a625e914451506bcd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d442ce7c4104d5683c12e67e4dcb5058159e9804", - "reference": "d442ce7c4104d5683c12e67e4dcb5058159e9804", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0dafb1175c366dd274eaa9a625e914451506bcd1", + "reference": "0dafb1175c366dd274eaa9a625e914451506bcd1", "shasum": "" }, "require": { @@ -3760,7 +3760,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.2" }, "funding": [ { @@ -3776,7 +3776,7 @@ "type": "tidelift" } ], - "time": "2023-08-04T06:48:08+00:00" + "time": "2023-08-15T05:34:23+00:00" }, { "name": "sebastian/cli-parser", @@ -3947,16 +3947,16 @@ }, { "name": "sebastian/comparator", - "version": "5.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c" + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/72f01e6586e0caf6af81297897bd112eb7e9627c", - "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", "shasum": "" }, "require": { @@ -3967,7 +3967,7 @@ "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^10.3" }, "type": "library", "extra": { @@ -4011,7 +4011,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" }, "funding": [ { @@ -4019,7 +4020,7 @@ "type": "github" } ], - "time": "2023-02-03T07:07:16+00:00" + "time": "2023-08-14T13:18:12+00:00" }, { "name": "sebastian/complexity", diff --git a/src/App.php b/src/App.php index 0b9fd51..9b15b30 100644 --- a/src/App.php +++ b/src/App.php @@ -30,7 +30,6 @@ class App */ public function __construct(string $configFile) { - // Define your configuration schema $this->config = new Configuration([ 'rclone' => Expect::structure([ diff --git a/src/Notification/NotificationInterface.php b/src/Notification/NotificationInterface.php index 11841de..bb130e5 100644 --- a/src/Notification/NotificationInterface.php +++ b/src/Notification/NotificationInterface.php @@ -6,6 +6,10 @@ namespace App\Notification; interface NotificationInterface { - static function factory(array $config): self; + /** + * @param string[] $config Configuration + */ + public static function factory(array $config): self; + public function send(string $title, string $message): void; } diff --git a/src/Notification/Ntfy.php b/src/Notification/Ntfy.php index 17b822b..b97ab6e 100644 --- a/src/Notification/Ntfy.php +++ b/src/Notification/Ntfy.php @@ -12,7 +12,6 @@ use InvalidArgumentException; class Ntfy implements NotificationInterface { - private Client $client; private string $topic = 'default'; /** * Initialize with configuration. @@ -28,9 +27,8 @@ class Ntfy implements NotificationInterface return $instance; } - public function __construct(Client $client) + public function __construct(private Client $client) { - $this->client = $client; } public function setTopic(string $topic): void diff --git a/src/Rclone/Rclone.php b/src/Rclone/Rclone.php index ca0844a..6077bdf 100644 --- a/src/Rclone/Rclone.php +++ b/src/Rclone/Rclone.php @@ -18,13 +18,6 @@ use Exception; */ class Rclone { - /** - * The logger instance. - */ - protected LoggerInterface $logger; - - protected string $rclonePath; - protected string $version = ""; /** @@ -35,10 +28,9 @@ class Rclone * * @param string $rclonePath Relative or absolute path */ - public function __construct(LoggerInterface $logger, string $rclonePath = "rclone") + public function __construct(protected LoggerInterface $logger, protected string $rclonePath = "rclone") { $this->rclonePath = $rclonePath; - $this->logger = $logger; $process = $this->exec('--version'); if (!$process->isSuccessful()) { diff --git a/tests/CommandBackupTest.php b/tests/CommandBackupTest.php index 86a26b8..4369e24 100644 --- a/tests/CommandBackupTest.php +++ b/tests/CommandBackupTest.php @@ -40,6 +40,20 @@ final class CommandBackupTest extends \PHPUnit\Framework\TestCase $this->assertStringContainsString('[ERROR] Configuration error:File "bad_file" does not exist.', $output); } + public function testNoCommand(): void + { + $applicationd = new Application('backup', "1.1.1"); + + $applicationd->add(new CommandBackup()); + + + $command = $applicationd->find('backup'); + $commandTester = new CommandTester($command); + $this->expectException(\Exception::class); + $commandTester->execute([]); + $this->fail('Exception was not thrown'); + } + public function testGoodConfig(): void { $applicationd = new Application('backup', "1.1.1");