Completed
Push — master ( df4948...3b59f8 )
by Michael
02:51
created

Sovereignty   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A preserveToSovereignty() 0 21 1
1
<?php
2
/**
3
 * Contains class Sovereignty.
4
 *
5
 * PHP version 5.4
6
 *
7
 * LICENSE:
8
 * This file is part of Yet Another Php Eve Api Library also know as Yapeal
9
 * which can be used to access the Eve Online API data and place it into a
10
 * database.
11
 * Copyright (C) 2016 Michael Cummings
12
 *
13
 * This program is free software: you can redistribute it and/or modify it
14
 * under the terms of the GNU Lesser General Public License as published by the
15
 * Free Software Foundation, either version 3 of the License, or (at your
16
 * option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21
 * for more details.
22
 *
23
 * You should have received a copy of the GNU Lesser General Public License
24
 * along with this program. If not, see
25
 * <http://www.gnu.org/licenses/>.
26
 *
27
 * You should be able to find a copy of this license in the LICENSE.md file. A
28
 * copy of the GNU GPL should also be available in the GNU-GPL.md file.
29
 *
30
 * @copyright 2016 Michael Cummings
31
 * @license   http://www.gnu.org/copyleft/lesser.html GNU LGPL
32
 * @author    Michael Cummings <[email protected]>
33
 */
34
namespace Yapeal\EveApi\Map;
35
36
use Yapeal\Log\Logger;
37
use Yapeal\Sql\PreserverTrait;
38
use Yapeal\Xml\EveApiReadWriteInterface;
39
40
/**
41
 * Class Sovereignty
42
 */
43
class Sovereignty extends MapSection
44
{
45
    use PreserverTrait;
46
    /** @noinspection MagicMethodsValidityInspection */
47
    /**
48
     * Constructor
49
     */
50
    public function __construct()
51
    {
52
        $this->mask = 8;
53
        $this->preserveTos = [
54
            'preserveToSovereignty'
55
        ];
56
    }
57
    /**
58
     * @param EveApiReadWriteInterface $data
59
     *
60
     * @return self Fluent interface.
61
     * @throws \LogicException
62
     */
63
    protected function preserveToSovereignty(EveApiReadWriteInterface $data)
64
    {
65
        $tableName = 'mapSovereignty';
66
        $sql = $this->getCsq()
67
            ->getDeleteFromTable($tableName);
68
        $this->getYem()
69
            ->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, $sql);
70
        $this->getPdo()
71
            ->exec($sql);
72
        $columnDefaults = [
73
            'allianceID' => null,
74
            'corporationID' => null,
75
            'factionID' => null,
76
            'solarSystemID' => null,
77
            'solarSystemName' => ''
78
        ];
79
        $xPath = '//solarSystems/row';
80
        $elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath);
81
        $this->attributePreserveData($elements, $columnDefaults, $tableName);
82
        return $this;
83
    }
84
}
85