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.

Spool::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Email;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Email\DataStructures\Config;
19
use O2System\Email\Protocols\Abstracts\AbstractProtocol;
20
use O2System\Spl\Traits\Collectors\ErrorCollectorTrait;
21
22
/**
23
 * Class Spool
24
 *
25
 * @package O2System\Email
26
 */
27
class Spool
28
{
29
    use ErrorCollectorTrait;
30
31
    /**
32
     * Spool::$config
33
     *
34
     * Spool configuration.
35
     *
36
     * @var Config
37
     */
38
    protected $config;
39
40
    /**
41
     * Spool::$log
42
     *
43
     * Spool log.
44
     *
45
     * @var array
46
     */
47
    protected $log = [];
48
49
    // ------------------------------------------------------------------------
50
51
    /**
52
     * Spool::__construct
53
     *
54
     * @param Config|null $config
55
     */
56
    public function __construct(Config $config = null)
57
    {
58
        if (empty($config)) {
59
            $config = new Config();
60
        }
61
62
        $this->setConfig($config);
63
    }
64
65
    // ------------------------------------------------------------------------
66
67
    /**
68
     * Spool::getConfig
69
     *
70
     * Gets spool configurations.
71
     *
72
     * @return Config
73
     */
74
    public function getConfig()
75
    {
76
        return $this->config;
77
    }
78
79
    // ------------------------------------------------------------------------
80
81
    /**
82
     * Spool::setConfig
83
     *
84
     * Sets spool config.
85
     *
86
     * @param Config $config
87
     *
88
     * @return static
89
     */
90
    public function setConfig(Config $config)
91
    {
92
        $this->config = $config;
93
94
        return $this;
95
    }
96
97
    // ------------------------------------------------------------------------
98
99
    /**
100
     * Spool::addLog
101
     *
102
     * Add spool log.
103
     *
104
     * @param $log
105
     */
106
    public function addLog($log)
107
    {
108
        $this->log[] = $log;
109
    }
110
111
    // ------------------------------------------------------------------------
112
113
    /**
114
     * Spool::getLog
115
     *
116
     * Gets spool log.
117
     *
118
     * @return array
119
     */
120
    public function getLog()
121
    {
122
        return $this->log;
123
    }
124
125
    // ------------------------------------------------------------------------
126
127
    /**
128
     * Spool::send
129
     *
130
     * @param \O2System\Email\Message $message
131
     *
132
     * @return bool
133
     */
134
    public function send(Message $message)
135
    {
136
        $protocolClass = '\O2System\Email\Protocols\\' . ucfirst($this->config->offsetGet('protocol')) . 'Protocol';
137
138
        if (class_exists($protocolClass)) {
139
            $protocol = new $protocolClass($this);
140
141
            if ($protocol instanceof AbstractProtocol) {
142
                return $protocol->send($message);
143
            }
144
        }
145
146
        return false;
147
    }
148
}