Completed
Push — master ( df80f0...840f28 )
by Rafal
11s
created

WinTeam   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 11 3
A getScore() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace App\GameBetting\Business\GamePoints\Score;
4
5
use App\GameBetting\Business\GamePoints\Config;
6
use App\GameBetting\Persistence\DataProvider\Result;
7
8
class WinTeam implements ScoreInterface
9
{
10
    /**
11
     * @param Result $result
12
     * @return bool
13
     */
14
    public function check(Result $result): bool
15
    {
16
        $check = false;
17
        if ($result->getFirstTeamResult() !== $result->getSecondTeamResult()
18
            && $result->getFirstTeamUserResult() !== $result->getSecondTeamUserResult()
19
        ) {
20
            $hasWinFirstTeam = $result->getFirstTeamResult() > $result->getSecondTeamResult();
21
            $hasUserWinFirstTeam = $result->getFirstTeamUserResult() > $result->getSecondTeamUserResult();
22
            $check = $hasWinFirstTeam === $hasUserWinFirstTeam;
23
        }
24
        return $check;
25
    }
26
27
    public function getScore(): int
28
    {
29
        return Config::WIN_TEAM;
30
    }
31
32
}