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

ApiVersionSetEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getApiVersion() 0 4 1
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