ActionCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 8 1
A hasAction() 0 10 2
1
<?php
2
3
namespace Cysha\Casino\Holdem\Game;
4
5
use Illuminate\Support\Collection;
6
7
class ActionCollection extends Collection
8
{
9
    public function all()
10
    {
11
        return $this
12
            ->map(function (Action $action) {
13
                return $action->toString();
14
            })
15
            ->toArray();
16
    }
17
18
    /**
19
     * @param int $actionValue
20
     *
21
     * @return bool
22
     */
23
    public function hasAction(int $actionValue): bool
24
    {
25
        $count = $this
26
            ->filter(function (Action $action) use ($actionValue) {
27
                return $action->action() === $actionValue;
28
            })
29
            ->count();
30
31
        return $count > 0 ? true : false;
32
    }
33
}
34