@@ -133,7 +133,7 @@ |
||
133 | 133 | /** |
134 | 134 | * Generate a random string of length. SECURE |
135 | 135 | * @param $length |
136 | - * @return null|string |
|
136 | + * @return string |
|
137 | 137 | * @throws \twhiston\twLib\TwLibException if string is generated non securely or result is null |
138 | 138 | */ |
139 | 139 | static public function String($length) |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | do { |
106 | 106 | $num = hexdec( |
107 | 107 | bin2hex(openssl_random_pseudo_bytes($bytes, $secure)) |
108 | - ) % $bits_max; |
|
108 | + ) % $bits_max; |
|
109 | 109 | if ($secure === false) { |
110 | 110 | throw new TwLibException( |
111 | - 'Non secure value generated. This is a system issue' |
|
111 | + 'Non secure value generated. This is a system issue' |
|
112 | 112 | ); |
113 | 113 | } |
114 | 114 | if ($num >= $range) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $string = bin2hex(openssl_random_pseudo_bytes($length, $secure)); |
149 | 149 | if ($secure === false) { |
150 | 150 | throw new TwLibException( |
151 | - 'Non secure string generated. This is a system issue' |
|
151 | + 'Non secure string generated. This is a system issue' |
|
152 | 152 | ); |
153 | 153 | } |
154 | 154 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | continue; |
117 | 117 | } // start over instead of accepting bias |
118 | 118 | // else |
119 | - $num = $num % $range; // to hell with security |
|
119 | + $num = $num % $range; // to hell with security |
|
120 | 120 | } |
121 | 121 | break; |
122 | 122 | } while (true); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // $class = $namespace.$class; |
42 | 42 | // } |
43 | 43 | |
44 | - if($namespace !== NULL){ |
|
44 | + if ($namespace !== NULL) { |
|
45 | 45 | $class = $namespace.$class; |
46 | 46 | } |
47 | 47 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | |
64 | 64 | } |
65 | 65 | //Make sure args are an array |
66 | - if($args !== NULL && $args !== FALSE){ |
|
66 | + if ($args !== NULL && $args !== FALSE) { |
|
67 | 67 | $args = (!is_array($args)) ? array($args) : $args; |
68 | - if(is_array($args)){ |
|
69 | - $c =count(array_filter(array_keys($args), 'is_string')); |
|
70 | - if(count(array_filter(array_keys($args), 'is_string')) > 0){ |
|
68 | + if (is_array($args)) { |
|
69 | + $c = count(array_filter(array_keys($args), 'is_string')); |
|
70 | + if (count(array_filter(array_keys($args), 'is_string')) > 0) { |
|
71 | 71 | $args = [$args]; |
72 | 72 | } |
73 | 73 | } |
@@ -75,8 +75,7 @@ |
||
75 | 75 | |
76 | 76 | $instance = Instantiate::instantiate($class, $args); |
77 | 77 | |
78 | - } |
|
79 | - catch (\Exception $e) { |
|
78 | + } catch (\Exception $e) { |
|
80 | 79 | throw $e; |
81 | 80 | } |
82 | 81 |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * Immutable constructor. |
27 | 27 | * This must be called from your child class to make the object immutable |
28 | 28 | */ |
29 | - public function __construct(){ |
|
30 | - if($this->constructed){ |
|
29 | + public function __construct() { |
|
30 | + if ($this->constructed) { |
|
31 | 31 | throw new ImmutableException('Immutable Object'); |
32 | 32 | } |
33 | 33 | $this->constructed = TRUE; |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @param $name |
39 | 39 | * @param $value |
40 | 40 | */ |
41 | - final public function __set($name, $value){ |
|
41 | + final public function __set($name, $value) { |
|
42 | 42 | throw new ImmutableException('Immutable Object'); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Throw an exception on cloning |
47 | 47 | */ |
48 | - final public function __clone(){ |
|
48 | + final public function __clone() { |
|
49 | 49 | throw new ImmutableException('Immutable Object'); |
50 | 50 | } |
51 | 51 |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | |
21 | 21 | private $index; |
22 | 22 | |
23 | - public function __construct(\PHPUnit_Framework_TestCase $test){ |
|
23 | + public function __construct(\PHPUnit_Framework_TestCase $test) { |
|
24 | 24 | $this->owner = $test; |
25 | 25 | $this->index = 0; |
26 | 26 | } |
27 | 27 | |
28 | - public function reset(){ |
|
28 | + public function reset() { |
|
29 | 29 | $index = 0; |
30 | 30 | } |
31 | 31 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | * @param array $context |
38 | 38 | * @return null |
39 | 39 | */ |
40 | - public function log($level, $message, array $context = array()){ |
|
40 | + public function log($level, $message, array $context = array()) { |
|
41 | 41 | |
42 | - $this->owner->assertArrayHasKey($this->index,$this->expected); |
|
43 | - $this->owner->assertStringStartsWith($this->expected[$this->index++],$message); |
|
42 | + $this->owner->assertArrayHasKey($this->index, $this->expected); |
|
43 | + $this->owner->assertStringStartsWith($this->expected[$this->index++], $message); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function setExpectedMessages(array $messages){ |
|
46 | + public function setExpectedMessages(array $messages) { |
|
47 | 47 | $this->expected = $messages; |
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -59,10 +59,10 @@ |
||
59 | 59 | * @param \twhiston\twLib\Reference\Reference $point |
60 | 60 | * @return mixed|null |
61 | 61 | */ |
62 | - public function &swap(Reference &$point) |
|
62 | + public function &swap(Reference&$point) |
|
63 | 63 | { |
64 | 64 | |
65 | - $tmp = &$this->point; |
|
65 | + $tmp = &$this->point; |
|
66 | 66 | $pr = &$point->getRef(); |
67 | 67 | $this->reset($pr); |
68 | 68 | $point->reset($tmp); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | public function offsetSet($offset, $value) |
75 | 75 | { |
76 | 76 | throw new TwLibException( |
77 | - 'Do not set stack references with the array operator' |
|
77 | + 'Do not set stack references with the array operator' |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | if (is_array($needles)) { |
55 | 55 | foreach ((array)$needles as $needle) { |
56 | 56 | if (($temp = strlen($haystack) - strlen( |
57 | - $needle |
|
57 | + $needle |
|
58 | 58 | )) >= 0 && strpos( |
59 | 59 | $haystack, |
60 | 60 | $needle, |
61 | 61 | $temp |
62 | - ) !== false |
|
62 | + ) !== false |
|
63 | 63 | ) { |
64 | 64 | return $needle; |
65 | 65 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $haystack, |
70 | 70 | $needles, |
71 | 71 | $temp |
72 | - ) !== false |
|
72 | + ) !== false |
|
73 | 73 | ) { |
74 | 74 | return true; |
75 | 75 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | static public function startsWith($haystack, $needles) |
30 | 30 | { |
31 | - if($haystack === null){ |
|
31 | + if ($haystack === null) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | if (is_array($needles)) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | static public function endsWith($haystack, $needles) |
56 | 56 | { |
57 | - if($haystack === null){ |
|
57 | + if ($haystack === null) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | if (is_array($needles)) { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | static public function contains($haystack, $needles) |
94 | 94 | { |
95 | - if($haystack === null){ |
|
95 | + if ($haystack === null) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | if (is_array($needles)) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $output = []; |
138 | 138 | foreach ($phrase as $item) { |
139 | 139 | $e = explode($item, $string); |
140 | - array_pop($e);//remove the rest of string entry |
|
140 | + array_pop($e); //remove the rest of string entry |
|
141 | 141 | $output[$item] = $e; |
142 | 142 | } |
143 | 143 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $output = []; |
164 | 164 | foreach ($phrase as $item) { |
165 | 165 | $e = explode($item, $string); |
166 | - array_shift($e);//remove the first item always |
|
166 | + array_shift($e); //remove the first item always |
|
167 | 167 | $output[$item] = $e; |
168 | 168 | } |
169 | 169 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | if (T_CLASS === $tokens[$index][0]) { |
60 | 60 | $index += 2; // Skip class keyword and whitespace |
61 | - $this->data[] = $namespace . '\\' . $tokens[$index][1]; |
|
61 | + $this->data[] = $namespace.'\\'.$tokens[$index][1]; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function filterData($needle) |
69 | 69 | { |
70 | - return array_values(array_filter($this->data, function ($var) use ($needle) { |
|
70 | + return array_values(array_filter($this->data, function($var) use ($needle) { |
|
71 | 71 | if (strpos($var, $needle) !== false) { |
72 | 72 | return true; |
73 | 73 | } |