Presentation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the FiveLab Resource package
7
 *
8
 * (c) FiveLab
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace FiveLab\Component\Resource\Presentation;
15
16
use FiveLab\Component\Resource\Resource\ResourceInterface;
17
18
/**
19
 * The default presentation for send the resource to the client.
20
 *
21
 * @author Vitaliy Zhuk <[email protected]>
22
 */
23
class Presentation implements PresentationInterface
24
{
25
    /**
26
     * @var ResourceInterface
27
     */
28
    private $resource;
29
30
    /**
31
     * @var int
32
     */
33
    private $statusCode;
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param int                    $statusCode
39
     * @param ResourceInterface|null $resource
40
     */
41 40
    public function __construct(int $statusCode, ResourceInterface $resource = null)
42
    {
43 40
        $this->resource = $resource;
44 40
        $this->statusCode = $statusCode;
45 40
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 40
    public function getResource(): ?ResourceInterface
51
    {
52 40
        return $this->resource;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 40
    public function getStatusCode(): int
59
    {
60 40
        return $this->statusCode;
61
    }
62
}
63