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

ApiVersionSetEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 29
ccs 6
cts 7
cp 0.8571
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 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