-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from DaveLiddament/feature/add-severity
Feature/add severity
- Loading branch information
Showing
73 changed files
with
888 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Common; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
class Severity | ||
{ | ||
public const WARNING = 'warning'; | ||
public const ERROR = 'error'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $severity; | ||
|
||
public static function fromStringOrNull(?string $severity): self | ||
{ | ||
if (null === $severity) { | ||
return new self(self::ERROR); | ||
} | ||
|
||
return new self($severity); | ||
} | ||
|
||
public static function error(): self | ||
{ | ||
return new self(self::ERROR); | ||
} | ||
|
||
public static function warning(): self | ||
{ | ||
return new self(self::WARNING); | ||
} | ||
|
||
private function __construct(string $severity) | ||
{ | ||
Assert::true(self::isValueValid($severity), "Invalid severity: $severity"); | ||
$this->severity = $severity; | ||
} | ||
|
||
public function getSeverity(): string | ||
{ | ||
return $this->severity; | ||
} | ||
|
||
public static function isValueValid(string $severity): bool | ||
{ | ||
return in_array($severity, [self::ERROR, self::WARNING], true); | ||
} | ||
|
||
public function isWarning(): bool | ||
{ | ||
return self::WARNING === $this->severity; | ||
} | ||
} |
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
Oops, something went wrong.