Update readme
This commit is contained in:
14
README.md
14
README.md
@@ -20,21 +20,21 @@ Create badges from objects or as standalone elements.
|
||||
|
||||
Any object that you would like to be able to be turned into a badge must implement `BadgeableInterface`.
|
||||
|
||||
This interface specifies a single method `getBadgeColour()` and is used to determine what colour the badge should be rendered as.
|
||||
This interface specifies a single method `getBadgeColour()` which expects an instance of the enum `BadgeColour` to be returned and is used to determine the colour of the rendered badge.
|
||||
|
||||
This method can contain as much logic in it as you'd like to return different colours of badge under different circumstances. EG:
|
||||
|
||||
```php
|
||||
// Job.php
|
||||
|
||||
public function getBadgeColour(): Badge
|
||||
public function getBadgeColour(): BadgeColour
|
||||
{
|
||||
return match ($this->getKind()) {
|
||||
JobKind::Investigation => Badge::BLUE,
|
||||
JobKind::Interrogation => Badge::RED,
|
||||
JobKind::Shootout => Badge::BLACK,
|
||||
JobKind::SipWhiskey => Badge::FOREST,
|
||||
default => Badge::GREY
|
||||
JobKind::Investigation => BadgeColour::BLUE,
|
||||
JobKind::Interrogation => BadgeColour::RED,
|
||||
JobKind::Shootout => BadgeColour::BLACK,
|
||||
JobKind::SipWhiskey => BadgeColour::FOREST,
|
||||
default => BadgeColour::GREY
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user