GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 8c9ef9...09fa7c )
by Carsten
09:15 queued 11s
created

AutoInsertingPdoItemCodes   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 40
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 15 2
A get() 0 14 2
1
<?php
2
namespace Germania\Nav\ItemCodes;
3
4
use Germania\Nav\ItemCodes\Actions\InsertOrUpdateItemCode;
5
6
class AutoInsertingPdoItemCodes extends PdoItemCodes
7
{
8 8
    public function push(ItemCodeInterface $itemcode)
9
    {
10 8
        $code = $itemcode->getCode();
11
12 8
        if (!$this->has($code)):
13 8
            $inserter = new InsertOrUpdateItemCode($this->pdo, $this->table_name, $this->logger);
14 8
	        $result = $inserter->execute($itemcode);
15 8
	        $this->logger->notice("Inserted missing Item code '{code}'", [
16 8
                'code' => $code,
17 8
                'result' => $result
18
            ]);
19
        endif;
20
21 8
        return parent::push($itemcode);
22
    }
23
24
25
    /**
26
     * Alias for autoGet()
27
     *
28
     * @param  string $itemcode_str Item code string
29
     * @return ItemCode
30
     */
31 8
    public function get($itemcode_str)
32
    {
33
        // Grab Item code instance from container:
34 8
        if ($this->has($itemcode_str)):
35 4
            return parent::get($itemcode_str); 
36
           endif;
37
38
        // So its missing in the database:
39
        // create new Instance and push it to the container.
40 4
        $itemcode = new ItemCode;
41 4
    	$itemcode->setCode($itemcode_str)->setName($itemcode_str);
42 4
    	$this->push($itemcode);
43 4
    	return $itemcode;
44
    }
45
}
46