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 ( 4032bb...90a43b )
by Steeven
02:53
created

Email::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
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
namespace O2System\Framework\Services;
14
15
16
use O2System\Email\DataStructures\Config;
17
use O2System\Email\Message;
18
use O2System\Email\Spool;
19
use O2System\Spl\Traits\Collectors\ConfigCollectorTrait;
20
use O2System\Spl\Traits\Collectors\ErrorCollectorTrait;
21
22
/**
23
 * Class Email
24
 * @package O2System\Framework\Services
25
 */
26
class Email extends Message
27
{
28
    use ConfigCollectorTrait;
29
    use ErrorCollectorTrait;
30
31
    /**
32
     * Email::__construct
33
     */
34
    public function __construct()
35
    {
36
        if ($config = config()->loadFile('email', true)) {
0 ignored issues
show
Bug introduced by
The method loadFile() does not exist on O2System\Kernel\DataStructures\Config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        if ($config = config()->/** @scrutinizer ignore-call */ loadFile('email', true)) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            $this->setConfig($config->getArrayCopy());
38
        }
39
    }
40
41
    // ------------------------------------------------------------------------
42
43
    /**
44
     * Email::subject
45
     *
46
     * @param string $subject
47
     *
48
     * @return Message
49
     */
50
    public function subject($subject)
51
    {
52
        $subject = language()->getLine($subject);
53
54
        return parent::subject($subject);
55
    }
56
57
    // ------------------------------------------------------------------------
58
59
    /**
60
     * Email::with
61
     *
62
     * @param mixed $vars
63
     * @param mixed $value
64
     *
65
     * @return static
66
     */
67
    public function with($vars, $value = null)
68
    {
69
        view()->with($vars, $value);
70
71
        return $this;
72
    }
73
74
    // ------------------------------------------------------------------------
75
76
    /**
77
     * Email::template
78
     *
79
     * @param string $filename
80
     * @param array $vars
81
     *
82
     * @return static
83
     */
84
    public function template($filename, array $vars = [])
85
    {
86
        if ($view = view()->load($filename, $vars, true)) {
87
            $this->body($view);
88
        }
89
90
        return $this;
91
    }
92
93
    // ------------------------------------------------------------------------
94
95
    /**
96
     * Email::send
97
     *
98
     * @return bool
99
     */
100
    public function send()
101
    {
102
        $spool = new Spool(new Config($this->config));
103
104
        if ($spool->send($this)) {
105
            return true;
106
        }
107
108
        $this->setErrors($spool->getErrors());
109
110
        return false;
111
    }
112
}