Config::getMailFrom()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace SiteChecker;
4
5
6
/**
7
 * Class Config
8
 * @package SiteChecker
9
 */
10
class Config
11
{
12
    public $checkImages = true;
13
    public $checkCSS = true;
14
    public $checkJS = true;
15
    public $showFullTags = false;
16
    public $showOnlyProblems = false;
17
    public $checkExternal = false;
18
    public $reportEmail = null;
19
    public $reportEmailFrom = null;
20
    /**
21
     * It's not okay to have links with whitespaces, but browsers
22
     * usually fix it, so let's ignore it in most cases
23
     */
24
    public $ignoreWhiteSpaces = true;
25
    public $cookies = [];
26
    public $excludedUrls = [];
27
    public $includedUrls = [];
28
29
    /**
30
     * @return array
31
     */
32
    public function getCookies()
33
    {
34
        $cookies = [];
35
        foreach ($this->cookies as $cookie) {
36
            $cookies[] = (array)$cookie;
37
        }
38
        return (array)$cookies;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getReportEmailAddresses()
45
    {
46
        if (stristr($this->reportEmail, ',')) {
47
            return explode(',', $this->reportEmail);
48
        }
49
50
        return [$this->reportEmail];
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getMailFrom()
57
    {
58
        if (!empty($this->reportEmailFrom)) {
59
            return $this->reportEmailFrom;
60
        }
61
62
        $addresses = $this->getReportEmailAddresses();
63
        return $addresses[0];
64
65
    }
66
}
67