ChipPotCollection::remove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Cysha\Casino\Holdem\Game;
4
5
use Cysha\Casino\Game\Chips;
6
use Illuminate\Support\Collection;
7
8
class ChipPotCollection extends Collection
9
{
10
    /**
11
     * @return Chips
12
     */
13 1
    public function total(): Chips
14
    {
15
        return Chips::fromAmount($this->sum(function (ChipPot $chipPot) {
16 1
            return $chipPot->total()->amount();
17 1
        }));
18
    }
19
20
    /**
21
     * @var ChipPot
22
     *
23
     * @return ChipPotCollection
24
     */
25
    public function remove(ChipPot $removeChipPot)
26
    {
27 11
        return $this->reject(function (ChipPot $chipPot) use ($removeChipPot) {
28 11
            return $chipPot->equals($removeChipPot);
29 11
        })->values();
30
    }
31
}
32