Completed
Push — master ( 2c9995...0e68f4 )
by Dawid
02:01
created

ApiVersionSetEvent::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2.032
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Event\ApiVersion;
6
7
use Spiechu\SymfonyCommonsBundle\Annotation\Controller\ApiVersion;
8
use Symfony\Component\EventDispatcher\Event;
9
10
class ApiVersionSetEvent extends Event
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $apiVersion;
16
17
    /**
18
     * @param ApiVersion $apiVersion
19
     *
20
     * @throws \InvalidArgumentException When API version is not set
21
     */
22 1
    public function __construct(ApiVersion $apiVersion)
23
    {
24 1
        if (empty($apiVersion->getApiVersion())) {
25
            throw new \InvalidArgumentException('API version not set');
26
        }
27
28 1
        $this->apiVersion = $apiVersion->getApiVersion();
29 1
    }
30
31
    /**
32
     * @return string
33
     */
34 1
    public function getApiVersion(): string
35
    {
36 1
        return $this->apiVersion;
37
    }
38
}
39