ResponseData   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A data() 0 4 1
A totalDataCount() 0 4 1
A filteredDataCount() 0 8 2
1
<?php
2
3
namespace OpenSkill\Datatable\Data;
4
5
use Illuminate\Support\Collection;
6
7
8
/**
9
 * Class ResponseData
10
 * @package OpenSkill\Datatable\Data
11
 *
12
 * Will hold all information that are necessary to create a response.
13
 */
14
class ResponseData
15
{
16
    /** @var Collection */
17
    private $data;
18
19
    /** @var null|int */
20
    private $dataCount;
21
22
    /** @var int */
23
    private $totalDataCount;
24
25
    /**
26
     * ResponseData constructor.
27
     * @param Collection $data the items that are returned from the provider
28
     * @param int $totalDataCount the count of the total items that the provider started with
29
     * @param int $dataCount the count of the total items that have been sorted out in search
30
     */
31
    public function __construct(Collection $data, $totalDataCount, $dataCount = null)
32
    {
33
        $this->data = $data;
34
        $this->dataCount = $dataCount;
35
        $this->totalDataCount = $totalDataCount;
36
    }
37
38
    /**
39
     * @return Collection
40
     */
41
    public function data()
42
    {
43
        return $this->data;
44
    }
45
46
    /**
47
     * @return int
48
     */
49
    public function totalDataCount()
50
    {
51
        return $this->totalDataCount;
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public function filteredDataCount()
58
    {
59
        if (is_null($this->dataCount)) {
60
            return count($this->data);
61
        }
62
63
        return $this->dataCount;
64
    }
65
}