Report   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
eloc 21
dl 0
loc 75
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getReportParams() 0 3 1
A getStatus() 0 3 1
A getDataSource() 0 3 1
A getReportFile() 0 3 1
A setReportParams() 0 3 1
A getReportPath() 0 3 1
A setDataSource() 0 3 1
A __construct() 0 20 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Jasper report integration for PHP
7
 *
8
 * @link      https://github.com/belgattitude/soluble-jasper
9
 * @author    Vanvelthem Sébastien
10
 * @copyright Copyright (c) 2017-2019 Vanvelthem Sébastien
11
 * @license   MIT
12
 */
13
14
namespace Soluble\Jasper;
15
16
use Soluble\Jasper\DataSource\Contract\DataSourceInterface;
17
use Soluble\Jasper\Exception\ReportFileNotFoundException;
18
use Soluble\Jasper\Report\ReportStatusInterface;
19
20
class Report implements ReportStatusInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    private $reportFile;
26
27
    /**
28
     * @var ReportParams
29
     */
30
    private $reportParams;
31
32
    /**
33
     * @var DataSourceInterface
34
     */
35
    private $dataSource;
36
37 26
    public function __construct(string $reportJRXMLFile, ReportParams $reportParams = null, DataSourceInterface $dataSource = null)
38
    {
39 26
        if (!file_exists($reportJRXMLFile)) {
40 1
            throw new ReportFileNotFoundException(
41 1
                sprintf(
42 1
                    'The report file "%s" cannot be found.',
43
                    $reportJRXMLFile
44
                )
45
            );
46
        }
47
48 25
        if ($reportParams !== null) {
49 15
            $this->setReportParams($reportParams);
50
        }
51
52 25
        if ($dataSource !== null) {
53 7
            $this->setDataSource($dataSource);
54
        }
55
56 25
        $this->reportFile = $reportJRXMLFile;
57 25
    }
58
59 15
    public function setReportParams(ReportParams $reportParams): void
60
    {
61 15
        $this->reportParams = $reportParams;
62 15
    }
63
64 15
    public function getReportParams(): ?ReportParams
65
    {
66 15
        return $this->reportParams;
67
    }
68
69 7
    public function setDataSource(DataSourceInterface $dataSource): void
70
    {
71 7
        $this->dataSource = $dataSource;
72 7
    }
73
74 15
    public function getDataSource(): ?DataSourceInterface
75
    {
76 15
        return $this->dataSource;
77
    }
78
79
    /**
80
     * @return string current jrxml report file
81
     */
82 20
    public function getReportFile(): string
83
    {
84 20
        return $this->reportFile;
85
    }
86
87 17
    public function getReportPath(): string
88
    {
89 17
        return dirname($this->reportFile);
90
    }
91
92 1
    public function getStatus(): string
93
    {
94 1
        return ReportStatusInterface::STATUS_FRESH;
95
    }
96
}
97