Completed
Push — master ( 7483cb...a139b5 )
by Vítězslav
03:58
created

UcetniObdobi   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 31
ccs 12
cts 14
cp 0.8571
rs 10
wmc 3
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createYearsFrom() 0 16 3
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt účetního období.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015,2016 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 Dokumentace
15
 * @author vitex
16
 */
17
class UcetniObdobi extends FlexiBee
18
{
19
    /**
20
     * Evidence FlexiBee
21
     * @var string
22
     */
23
    public $evidence = 'ucetni-obdobi';
24
25
    /**
26
     * Create requested Accounting period
27
     *
28
     * @param type $startYear
29
     * @param type $endYear
30
     */
31 1
    public function createYearsFrom($startYear, $endYear = null)
32
    {
33 1
        if (is_null($endYear)) {
34
            $endYear = date('Y');
35
        }
36
37 1
        for ($year = $startYear; $year <= $endYear; ++$year) {
38 1
            $obdobi = ['kod' => $year,
39 1
                'platiOdData' => $year.'-01-01T00:00:00',
40 1
                'platiDoData' => $year.'-12-31T23:59:59',
41 1
            ];
42 1
            $this->setData($obdobi);
43 1
            $result = $this->insertToFlexibee();
44 1
            $this->addStatusMessage(print_r($result, 1));
45 1
        }
46 1
    }
47
}
48