Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
feat: add status constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cawolf committed Jan 27, 2020
1 parent e53190b commit 5d1ef26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Instantiate the client class and pass the configuration as parameters:
```php
$data = new Phash\MonitoringData(
'monitoring id',
'ok',
Phash\MonitoringData::STATUS_OK,
'this detail message will be displayed if a tile is clicked by a user',
60,
1,
Expand Down
9 changes: 9 additions & 0 deletions src/MonitoringData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
namespace Phash;

use DateTimeInterface;
use RuntimeException;

class MonitoringData
{
public const STATUS_OK = 'ok';
public const STATUS_ERROR = 'error';

private const STATUSES = [self::STATUS_ERROR, self::STATUS_OK];

private $id;
private $status;
private $payload;
Expand All @@ -27,6 +33,9 @@ public function __construct(
DateTimeInterface $date,
?string $path
) {
if (!in_array($status, self::STATUSES, true)) {
throw new RuntimeException(sprintf('status must be one of [%s]', implode(',', self::STATUSES)));
}
$this->id = $id;
$this->status = $status;
$this->payload = $payload;
Expand Down

0 comments on commit 5d1ef26

Please sign in to comment.