Response::getDomainCommand()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3.4578

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 2
cts 7
cp 0.2857
crap 3.4578
rs 10
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace WebPresentation\ApplicationController;
6
7
use ReflectionClass;
8
use ReflectionException;
9
use Exception\ApplicationException;
10
11
class Response
12
{
13
    private ReflectionClass $domainCommand;
14
15
    private string $viewUrl;
16
17 2
    public function __construct(string $domainCommand, string $viewUrl)
18
    {
19 2
        $this->domainCommand = new ReflectionClass($domainCommand);
20 2
        $this->viewUrl = $viewUrl;
21 2
    }
22
23 2
    public function getDomainCommand(): DomainCommand
24
    {
25
        try {
26 2
            return $this->domainCommand->newInstance();
27
        } catch (ReflectionException $e) {
28
            throw new ApplicationException(
29
                $e->getMessage(),
30
                $e->getCode(),
31
                $e
32
            );
33
        }
34
    }
35
36 2
    public function getViewUrl(): string
37
    {
38 2
        return $this->viewUrl;
39
    }
40
}
41