@@ -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 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $output = []; |
130 | 130 | foreach ($phrase as $item) { |
131 | 131 | $e = explode($item, $string); |
132 | - array_pop($e);//remove the rest of string entry |
|
132 | + array_pop($e); //remove the rest of string entry |
|
133 | 133 | $output[$item] = $e; |
134 | 134 | } |
135 | 135 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $output = []; |
156 | 156 | foreach ($phrase as $item) { |
157 | 157 | $e = explode($item, $string); |
158 | - array_shift($e);//remove the first item always |
|
158 | + array_shift($e); //remove the first item always |
|
159 | 159 | $output[$item] = $e; |
160 | 160 | } |
161 | 161 |