Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed May 26, 2023
1 parent 080f5aa commit d09a20d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 9 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"laravel-notification-channels/discord": "^1.5",
"laravel-notification-channels/telegram": "^4.0",
"mtdowling/cron-expression": "^1.2",
"spatie/laravel-package-tools": "^1.14.0"
"spatie/laravel-package-tools": "^1.14.0",
"vlucas/phpdotenv": "^5.5"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
1 change: 1 addition & 0 deletions src/Checks/Base/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function shouldRun(): bool
}

$date = Date::now();
dump($this->expression);

return (new CronExpression($this->expression))->isDue($date->toDateTimeString());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Checks/Base/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Result

public ?CarbonInterface $ended_at;

public static function make(string $message = ''): self
public static function new(string $message = ''): self
{
return new self(Status::OK, $message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Checks/DebugModeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function run(): Result
{
$currentValue = config('app.debug');

$result = Result::make();
$result = Result::new();

$shouldBeText = $this->convertToText((bool) $this->shouldBe);
$currentText = $this->convertToText((bool) $currentValue);
Expand Down
35 changes: 35 additions & 0 deletions src/Checks/DotEnvCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Vormkracht10\LaravelOK\Checks;

use Dotenv\Dotenv;
use Vormkracht10\LaravelOK\Checks\Base\Check;
use Vormkracht10\LaravelOK\Checks\Base\Result;

class DotEnvCheck extends Check
{
protected array $required;

public function required(array $variables): self
{
$this->required = $variables;

return $this;
}

public function run(): Result
{
$result = Result::new();

$vars = collect(
Dotenv::parse(file_get_contents(base_path('.env')))
);

$missing = collect($this->required)
->filter(fn ($variable) => ! $vars->has($variable));

dd($missing);

return $result->ok();

Check failure on line 33 in src/Checks/DotEnvCheck.php

View workflow job for this annotation

GitHub Actions / phpstan

Unreachable statement - code above always terminates.
}
}
2 changes: 1 addition & 1 deletion src/Checks/EnvironmentCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function run(): Result
{
$currentValue = app()->environment();

$result = Result::make();
$result = Result::new();

return $this->shouldBe === $currentValue
? $result->ok()
Expand Down
2 changes: 1 addition & 1 deletion src/Checks/Traits/ChecksDatabaseQueryCountResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function run(): Result
{
$currentCount = $this->queryCount();

$result = Result::make();
$result = Result::new();

return $this->checkExpectedCount($currentCount)
? $result->ok()
Expand Down
4 changes: 2 additions & 2 deletions src/Checks/Traits/ChecksUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ public function run(): Result
return $this->failedResult();
}

return Result::make()
return Result::new()

Check failure on line 91 in src/Checks/Traits/ChecksUrl.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to static method new() on an unknown class Spatie\Health\Checks\Result.
->ok()
->shortSummary('Reachable');
}

protected function failedResult(): Result

Check failure on line 96 in src/Checks/Traits/ChecksUrl.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Health\Checks\Checks\CheckUrl::failedResult() has invalid return type Spatie\Health\Checks\Result.
{
return Result::make()
return Result::new()

Check failure on line 98 in src/Checks/Traits/ChecksUrl.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to static method new() on an unknown class Spatie\Health\Checks\Result.
->failed()
->shortSummary('Unreachable')
->notificationMessage($this->failureMessage ?? "Pinging {$this->getName()} failed.");

Check failure on line 101 in src/Checks/Traits/ChecksUrl.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Spatie\Health\Checks\Checks\CheckUrl::getName().
Expand Down
4 changes: 2 additions & 2 deletions src/Checks/Traits/RendersWebPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ public function run(): Result
return $this->failedResult();
}

return Result::make()
return Result::new()
->ok()
->shortSummary('Reachable');
}

protected function failedResult(): Result
{
return Result::make()
return Result::new()
->failed()
->shortSummary('Unreachable')
->notificationMessage($this->failureMessage ?? "Pinging {$this->getName()} failed.");
Expand Down

0 comments on commit d09a20d

Please sign in to comment.