Completed
Push — master ( 3fab57...455a7d )
by Peter
14:19
created

MaxScoreAwareTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxScore() 0 8 2
A setMaxScore() 0 9 2
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Traits;
14
15
use Maslosoft\Manganel\Interfaces\MaxScoreAwareInterface;
16
use UnexpectedValueException;
17
18
/**
19
 * MaxScoreAwareTrait
20
 *
21
 * @see MaxScoreAwareInterface
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
trait MaxScoreAwareTrait
25
{
26
27
	private $maxScore = 0.0;
28
29 1
	public function getMaxScore()
30
	{
31 1
		if (!$this instanceof MaxScoreAwareInterface)
32
		{
33
			throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, MaxScoreAwareInterface::class)); // @codeCoverageIgnore
34
		}
35 1
		return $this->maxScore;
36
	}
37
38 1
	public function setMaxScore($score)
39
	{
40 1
		if (!$this instanceof MaxScoreAwareInterface)
41
		{
42
			throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, MaxScoreAwareInterface::class)); // @codeCoverageIgnore
43
		}
44 1
		$this->maxScore = floatval($score);
45 1
		return $this;
46
	}
47
48
}
49