Completed
Push — master ( 75748b...36048b )
by Michael
06:58
created

ErrorList::preserveEveApi()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 35
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 3
Metric Value
c 3
b 0
f 3
dl 0
loc 35
rs 8.8571
cc 3
eloc 29
nc 4
nop 3
1
<?php
2
/**
3
 * Contains class ErrorList.
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\Eve;
35
36
use Yapeal\Log\Logger;
37
use Yapeal\Sql\PreserverTrait;
38
use Yapeal\Xml\EveApiReadWriteInterface;
39
40
/**
41
 * Class ErrorList
42
 */
43
class ErrorList extends EveSection
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: getCsq, getPdo
Loading history...
44
{
45
    use PreserverTrait;
46
47
    /** @noinspection MagicMethodsValidityInspection */
48
    /**
49
     * Constructor
50
     */
51
    public function __construct()
52
    {
53
        $this->mask = 32;
54
        $this->preserveTos = [
55
            'preserveToErrorList'
56
        ];
57
    }
58
    /**
59
     * @param EveApiReadWriteInterface $data
60
     *
61
     * @return self Fluent interface.
62
     * @throws \LogicException
63
     */
64
    protected function preserveToErrorList(EveApiReadWriteInterface $data)
65
    {
66
        $tableName = 'eveErrorList';
67
        $sql = $this->getCsq()
68
                    ->getDeleteFromTable($tableName);
69
        $this->getYem()
70
             ->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, $sql);
71
        $this->getPdo()
72
             ->exec($sql);
73
        $columnDefaults = [
74
            'errorCode' => null,
75
            'errorText' => null
76
        ];
77
        $xPath = '//errors/row';
78
        $elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath);
79
        $this->attributePreserveData($elements, $columnDefaults, $tableName);
80
        return $this;
81
    }
82
}
83