From a0ae4ba98cdce3dadb7278278145d45d9c283e62 Mon Sep 17 00:00:00 2001 From: henzeb Date: Sun, 5 Jun 2022 12:25:22 +0200 Subject: [PATCH] labels method should be static --- docs/labels.md | 2 +- src/Concerns/Labels.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/labels.md b/docs/labels.md index a5f0a26..cd47c03 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -15,7 +15,7 @@ enum YourEnum { case ENUM; case NO_LABEL; - public function labels(): array + public static function labels(): array { return [ 'ENUM' => 'Your label'; diff --git a/src/Concerns/Labels.php b/src/Concerns/Labels.php index e4dd6bb..7ea9c8d 100644 --- a/src/Concerns/Labels.php +++ b/src/Concerns/Labels.php @@ -4,14 +4,14 @@ trait Labels { - public function labels(): array + public static function labels(): array { return []; } final public function label(): ?string { - return $this->labels()[$this->name] + return self::labels()[$this->name] ?? (method_exists($this, 'value') ? $this->value() : null) ?? $this->value ?? $this->name;