Completed
Branch develop (e9fd73)
by Benjamin
03:23
created

NoVersionException::getVersionMessage()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Obblm\Core\Exception;
4
5
use Obblm\Core\Entity\Player;
6
use Obblm\Core\Entity\Team;
7
8
class NoVersionException extends \Exception implements ExceptionInterface
9
{
10
    public function __construct(object $on = null)
11
    {
12
        parent::__construct($this->getVersionMessage($on));
0 ignored issues
show
Bug introduced by
It seems like $on can also be of type null; however, parameter $on of Obblm\Core\Exception\NoV...on::getVersionMessage() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

12
        parent::__construct($this->getVersionMessage(/** @scrutinizer ignore-type */ $on));
Loading history...
13
    }
14
15
    private function getVersionMessage(object $on):?string
16
    {
17
        if ($on instanceof Team) {
18
            return "No version available for team : " . $on->getName();
19
        } elseif ($on instanceof Player) {
20
            return "No version available for player : " . $on->getName();
21
        }
22
        return "No version available";
23
    }
24
}
25