SkladovyPohybPolozka::addSerialNumber()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
c 0
b 0
f 0
rs 9.9666
cc 4
nc 3
nop 2
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt položky skladového pohybu.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015-2018 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Položka skladového pohybu
13
 *
14
 * @link https://demo.flexibee.eu/c/demo/skladovy-pohyb-polozka/properties
15
 */
16
class SkladovyPohybPolozka extends FlexiBeeRW
17
{
18
19
    use Stitky;
20
    /**
21
     * Evidence užitá objektem.
22
     *
23
     * @var string
24
     */
25
    public $evidence = 'skladovy-pohyb-polozka';
26
27
    /**
28
     * Add Items Serial Number
29
     * 
30
     * @param type $number
31
     * @param type $isMain
0 ignored issues
show
Bug introduced by
The type FlexiPeeHP\type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
     * 
33
     * @return boolean Success
34
     */
35
    public function addSerialNumber($number, $isMain = false)
36
    {
37
        $numberBranch['kod'] = $number;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$numberBranch was never initialized. Although not strictly required by PHP, it is generally a good practice to add $numberBranch = array(); before regardless.
Loading history...
38
        $crrentSerialNumbers = $this->getDataValue('vyrobniCislaPrijata');
39
        if ($isMain) {
40
            if (!empty($crrentSerialNumbers)) {
41
                foreach (array_keys($crrentSerialNumbers) as $serialNumberID) {
42
                    unset($this->data['vyrobniCislaPrijata'][$serialNumberID]['vyrobnicislohlav']);
43
                }
44
            }
45
            $numberBranch['vyrobnicislohlav'] = 1;
46
        }
47
        $this->setDataValue('mnozMj', count($crrentSerialNumbers) + 1);
48
        return $this->addArrayToBranch($numberBranch, 'vyrobniCislaPrijata');
49
    }
50
}
51