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.
Completed
Pull Request — master (#8)
by Pascal
01:50
created

BaseObject::openSSLCheck()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 0
1
<?php
2
/******************************************************************************
3
 * This file is part of the Phactor PHP project. You can always find the latest
4
 * version of this class and project at: https://github.com/ionux/phactor
5
 *
6
 * Copyright (c) 2015-2017 Rich Morgan, [email protected]
7
 *
8
 * The MIT License (MIT)
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11
 * this software and associated documentation files (the "Software"), to deal in
12
 * the Software without restriction, including without limitation the rights to
13
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
 * the Software, and to permit persons to whom the Software is furnished to do so,
15
 * subject to the following conditions:
16
 *
17
 * The above copyright notice and this permission notice shall be included in all
18
 * copies or substantial portions of the Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
 ******************************************************************************/
27
28
namespace Phactor;
29
30
/**
31
 * The very base, primary Object trait for the Phactor library.
32
 *
33
 * @author Rich Morgan <[email protected]>
34
 */
35
trait BaseObject
36
{
37
    /**
38
     * Set this to false if you want to disable the
39
     * various parameter checks to improve performance.
40
     * It could definitely break things if you don't
41
     * ensure the values are legitimate yourself, though!
42
     *
43
     * @var boolean
44
     */
45
    private $param_checking = true;
46
47
    /**
48
     * @var array
49
     */
50
    private $bytes = array();
51
52
    /**
53
     * @var boolean
54
     */
55
    private $openSSL = false;
56
57
    /**
58
     * Generates an array of byte values.
59
     *
60
     * @return array $tempvals An array of bytes.
61
     */
62
    private function genBytes()
63
    {
64
        $tempvals = array();
65
66
        for ($x = 0; $x < 256; $x++) {
67
            $tempvals[$x] = chr($x);
68
        }
69
70
        return $tempvals;
71
    }
72
73
    /**
74
     * Trims() and strtolowers() the value.
75
     *
76
     * @param  mixed $value  The value to clean.
77
     * @return string        The clean value.
78
     */
79
    private function prepAndClean($value)
80
    {
81
        return strtolower(trim($value));
82
    }
83
84
    /**
85
     * Checks if a value is null, nothing or empty array.
86
     *
87
     * @param  mixed $value  The value to be checked.
88
     * @return boolean       Either true or false.
89
     */
90
    private function nullTest($value)
91
    {
92
        return (is_null($value) || $value === "" || $value === array());
93
    }
94
95
    /**
96
     * Checks if a value is an object.
97
     *
98
     * @param  mixed $value  The value to be checked.
99
     * @return boolean       Either true or false.
100
     */
101
    private function objTest($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
102
    {
103
        return (($this->nullTest($value) === false) && is_object($value));
104
    }
105
106
    /**
107
     * Checks if a value is an array.
108
     *
109
     * @param  mixed $value  The value to be checked.
110
     * @return boolean       Either true or false.
111
     */
112
    private function arrTest($value)
113
    {
114
        return (($this->nullTest($value) === false) && is_array($value));
115
    }
116
117
    /**
118
     * Checks if a value is an boolean.
119
     *
120
     * @param  mixed $value  The value to be checked.
121
     * @return boolean       Either true or false.
122
     */
123
    private function boolTest($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
124
    {
125
        return (($this->nullTest($value) === false) && is_bool($value));
126
    }
127
128
    /**
129
     * Checks if a value is a resource.
130
     *
131
     * @param  mixed $value  The value to be checked.
132
     * @return boolean       Either true or false.
133
     */
134
    private function resTest($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
135
    {
136
        return (($this->nullTest($value) === false) && is_resource($value));
137
    }
138
139
    /**
140
     * Checks if a value is a string.
141
     *
142
     * @param  mixed $value  The value to be checked.
143
     * @return boolean       Either true or false.
144
     */
145
    private function strTest($value)
146
    {
147
        return (($this->nullTest($value) === false) && is_string($value));
148
    }
149
150
    /**
151
     * Checks if the OpenSSL extension is loaded.
152
     *
153
     * @throws \Exception
154
     */
155
    private function openSSLCheck()
156
    {
157
        if ($this->openSSL === false) {
158
            if (extension_loaded('openssl')) {
159
                $this->openSSL = true;
160
            } else {
161
                throw new \Exception('Phactor requires the OpenSSL extension for PHP. Please install this extension to use the Phactor math library.');
162
            }
163
        }
164
    }
165
}
166