-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
174 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Values; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
final class SyncResult | ||
{ | ||
public const TYPE_SUCCESS = 1; | ||
public const TYPE_ERROR = 2; | ||
public const TYPE_SKIPPED = 3; | ||
|
||
private function __construct(public string $path, public int $type, public ?string $error) | ||
{ | ||
Assert::oneOf($type, [ | ||
SyncResult::TYPE_SUCCESS, | ||
SyncResult::TYPE_ERROR, | ||
SyncResult::TYPE_SKIPPED, | ||
]); | ||
} | ||
|
||
public static function success(string $path): self | ||
{ | ||
return new self($path, self::TYPE_SUCCESS, null); | ||
} | ||
|
||
public static function skipped(string $path): self | ||
{ | ||
return new self($path, self::TYPE_SKIPPED, null); | ||
} | ||
|
||
public static function error(string $path, ?string $error): self | ||
{ | ||
return new self($path, self::TYPE_ERROR, $error); | ||
} | ||
|
||
public function isSuccess(): bool | ||
{ | ||
return $this->type === self::TYPE_SUCCESS; | ||
} | ||
|
||
public function isSkipped(): bool | ||
{ | ||
return $this->type === self::TYPE_SKIPPED; | ||
} | ||
|
||
public function isError(): bool | ||
{ | ||
return $this->type === self::TYPE_ERROR; | ||
} | ||
|
||
public function isValid(): bool | ||
{ | ||
return $this->isSuccess() || $this->isSkipped(); | ||
} | ||
} |
Oops, something went wrong.