Completed
Pull Request — master (#81)
by Sebastian
20:20 queued 12:24
created

Enum   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doesntEqual() 0 4 1
A toCollection() 0 4 1
A allAsRegex() 0 6 1
1
<?php
2
3
namespace App\Foundation\Enums;
4
5
use Illuminate\Support\Collection;
6
use MyCLabs\Enum\Enum as BaseEnum;
7
8
abstract class Enum extends BaseEnum
9
{
10
    public function doesntEqual(Enum $enum): bool
11
    {
12
        return ! $this->equals($enum);
13
    }
14
15
    public static function toCollection():  Collection
16
    {
17
        return collect(static::toArray());
18
    }
19
20
    public static function allAsRegex(): string
21
    {
22
        return collect(static::values())->map(function ($value) {
23
            return "({$value})";
24
        })->implode('|');
25
    }
26
}
27