JsonApiDocumentView::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Bundle\JsonApiBundle\Response;
5
6
use Mikemirten\Bundle\JsonApiBundle\Response\Behaviour\HttpAttributesAwareInterface;
7
use Mikemirten\Bundle\JsonApiBundle\Response\Behaviour\HttpAttributesContainer;
8
use Mikemirten\Component\JsonApi\Document\AbstractDocument;
9
10
/**
11
 * Document Json API view
12
 * Passes a document to a request handler along with status code and headers
13
 *
14
 * @package Mikemirten\Bundle\JsonApiBundle\Response
15
 */
16
class JsonApiDocumentView implements HttpAttributesAwareInterface
17
{
18
    use HttpAttributesContainer;
19
20
    /**
21
     * Json API document
22
     *
23
     * @var AbstractDocument
24
     */
25
    protected $document;
26
27
    /**
28
     * JsonApiDocumentResponse constructor.
29
     *
30
     * @param AbstractDocument $document
31
     * @param int              $status
32
     * @param array            $headers
33
     */
34 2
    public function __construct(AbstractDocument $document, int $status = 200, array $headers = [])
35
    {
36 2
        $this->document   = $document;
37 2
        $this->statusCode = $status;
38 2
        $this->headers    = $headers;
39 2
    }
40
41
    /**
42
     * Get document
43
     *
44
     * @return AbstractDocument
45
     */
46 1
    public function getDocument(): AbstractDocument
47
    {
48 1
        return $this->document;
49
    }
50
}