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

WinScoreRightDiff   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getScore() 0 3 1
A check() 0 10 3
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 WinScoreRightDiff 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->getFirstTeamUserResult() !== null && $result->getSecondTeamUserResult() !== null) {
18
            $diffUserResult = $result->getFirstTeamUserResult() - $result->getSecondTeamUserResult();
19
            $diffGameResult = $result->getFirstTeamResult() - $result->getSecondTeamResult();
20
            $check = ($diffGameResult === $diffUserResult);
21
        }
22
23
        return $check;
24
    }
25
26
    public function getScore(): int
27
    {
28
        return Config::WIN_SCORE_DIFF;
29
    }
30
31
32
}