Completed
Push — master ( 1c14d6...2c9995 )
by Dawid
02:08
created

ApiVersionSetEvent::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
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
    public function __construct(ApiVersion $apiVersion)
23
    {
24
        if (empty($apiVersion->getApiVersion())) {
25
            throw new \InvalidArgumentException('API version not set');
26
        }
27
28
        $this->apiVersion = $apiVersion->getApiVersion();
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getApiVersion(): string
35
    {
36
        return $this->apiVersion;
37
    }
38
}
39