Test Failed
Push — master ( 9ca4a5...db00ed )
by Vítězslav
11:19
created

UcetniObdobi   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 72.21%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 39
ccs 13
cts 18
cp 0.7221
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B createYearsFrom() 0 22 4
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt účetního období.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015-2017 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Class for Accounting period handling.
13
 *
14
 * @link https://demo.flexibee.eu/c/demo/ucetni-obdobi/properties Položky evidence
15
 * @author vitex
16
 */
17
class UcetniObdobi extends FlexiBeeRW
18
{
19
    /**
20
     * Evidence FlexiBee
21
     * @var string
22
     */
23
    public $evidence = 'ucetni-obdobi';
24
25
    /**
26
     * Create requested Accounting period
27
     *
28
     * @param int $startYear first year to create
29
     * @param int $endYear   last yar to create - default is current year
30
     *
31
     * @return array Results
32
     */
33 1
    public function createYearsFrom($startYear, $endYear = null)
34
    {
35 1
        $result = [];
36 1
        if (is_null($endYear)) {
37
            $endYear = date('Y');
38
        }
39
40 1
        for ($year = $startYear; $year <= $endYear; ++$year) {
41 1
            $obdobi = ['kod' => $year,
42 1
                'platiOdData' => $year.'-01-01T00:00:00',
43 1
                'platiDoData' => $year.'-12-31T23:59:59',
44 1
            ];
45 1
            if ($this->idExists('code:'.$year)) {
0 ignored issues
show
Documentation introduced by
'code:' . $year is of type string, but the function expects a boolean|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46 1
                $this->addStatusMessage(sprintf(_('%s already exists.'), $year));
47 1
            } else {
48
                $this->setData($obdobi);
49
                $result[] = $this->insertToFlexibee();
50
            $this->dataReset();
51
        }
52 1
        }
53 1
        return $result;
54
    }
55
}
56