Completed
Push — master ( 6d93bd...5be270 )
by smiley
03:09
created
src/Crypto/SecretBox.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-class SecretBox extends CryptoBox{
15
+class SecretBox extends CryptoBox {
16 16
 
17 17
 	/**
18 18
 	 * @param string      $message
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 		sodium_memzero($message);
31 31
 
32
-		if($nonce_bin !== null){
32
+		if ($nonce_bin !== null) {
33 33
 			sodium_memzero($nonce_bin);
34 34
 		}
35 35
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 		$this->message = sodium_crypto_secretbox_open($box_bin, $nonce_bin, $this->keypair->secret);
50 50
 
51
-		if($this->message === false){
51
+		if ($this->message === false) {
52 52
 			throw new CryptoException('invalid box'); // @codeCoverageIgnore
53 53
 		}
54 54
 
Please login to merge, or discard this patch.
src/Crypto/CryptoBox.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @throws \chillerlan\Traits\Crypto\CryptoException
55 55
 	 */
56
-	public function __construct(array $properties = null){
56
+	public function __construct(array $properties = null) {
57 57
 
58
-		if(!extension_loaded('sodium') || !function_exists('sodium_memzero')){
58
+		if (!extension_loaded('sodium') || !function_exists('sodium_memzero')) {
59 59
 			throw new CryptoException('sodium extension (PHP 7.2+) required!'); // @codeCoverageIgnore
60 60
 		}
61 61
 
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 	 * @return void
70 70
 	 * @throws \chillerlan\Traits\Crypto\CryptoException
71 71
 	 */
72
-	protected function checkKeypair(int $secretLength = null, int $PublicLength = null){
72
+	protected function checkKeypair(int $secretLength = null, int $PublicLength = null) {
73 73
 
74
-		if($secretLength !== null){
75
-			if(!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength){
74
+		if ($secretLength !== null) {
75
+			if (!$this->keypair->secret || strlen($this->keypair->secret) !== $secretLength) {
76 76
 				throw new CryptoException('invalid secret key');
77 77
 			}
78 78
 		}
79 79
 
80
-		if($PublicLength !== null){
81
-			if(!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength){
80
+		if ($PublicLength !== null) {
81
+			if (!$this->keypair->public || strlen($this->keypair->public) !== $PublicLength) {
82 82
 				throw new CryptoException('invalid public key');
83 83
 			}
84 84
 		}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	protected function checkMessage(string $message):string {
95 95
 		$message = trim($message);
96 96
 
97
-		if(empty($message)){
97
+		if (empty($message)) {
98 98
 			throw new CryptoException('invalid message');
99 99
 		}
100 100
 
Please login to merge, or discard this patch.
src/Crypto/SignKeypair.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-class SignKeypair extends CryptoKeypair{
15
+class SignKeypair extends CryptoKeypair {
16 16
 
17 17
 	/** @inheritdoc */
18 18
 	public function create(string &$seed_bin = null):CryptoKeyInterface{
19 19
 
20
-		if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES){
20
+		if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES) {
21 21
 			throw new CryptoException('invalid seed length');
22 22
 		}
23 23
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 		sodium_memzero($keypair);
33 33
 
34
-		if($seed_bin !== null){
34
+		if ($seed_bin !== null) {
35 35
 			sodium_memzero($seed_bin);
36 36
 		}
37 37
 
Please login to merge, or discard this patch.
src/Crypto/SealedBox.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-class SealedBox extends CryptoBox{
15
+class SealedBox extends CryptoBox {
16 16
 
17 17
 	/** @inheritdoc */
18 18
 	public function create(string &$message):CryptoBoxInterface{
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		sodium_memzero($keypair);
36 36
 		sodium_memzero($box_bin);
37 37
 
38
-		if($this->message === false){
38
+		if ($this->message === false) {
39 39
 			throw new CryptoException('invalid box'); // @codeCoverageIgnore
40 40
 		}
41 41
 
Please login to merge, or discard this patch.
src/Crypto/CryptoTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-trait CryptoTrait{
15
+trait CryptoTrait {
16 16
 
17 17
 	/**
18 18
 	 * @var \chillerlan\Traits\Crypto\CryptoKeyInterface
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @return $this
27 27
 	 */
28
-	protected function setBoxKeypair(string $secret_hex = null, string $public_hex = null){
28
+	protected function setBoxKeypair(string $secret_hex = null, string $public_hex = null) {
29 29
 		return $this->setCryptoKeyInterface(BoxKeypair::class, $secret_hex, $public_hex);
30 30
 	}
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return $this
37 37
 	 */
38
-	protected function setSignKeypair(string $secret_hex = null, string $public_hex = null){
38
+	protected function setSignKeypair(string $secret_hex = null, string $public_hex = null) {
39 39
 		return $this->setCryptoKeyInterface(SignKeypair::class, $secret_hex, $public_hex);
40 40
 	}
41 41
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @return $this
46 46
 	 */
47
-	protected function setKeypair(CryptoKeyInterface $keypair){
47
+	protected function setKeypair(CryptoKeyInterface $keypair) {
48 48
 		unset($this->cryptoKeyInterface);
49 49
 
50 50
 		$this->cryptoKeyInterface = $keypair;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return $this
61 61
 	 */
62
-	private function setCryptoKeyInterface(string $type_fqcn, string &$secret_hex = null, string &$public_hex = null){
62
+	private function setCryptoKeyInterface(string $type_fqcn, string &$secret_hex = null, string &$public_hex = null) {
63 63
 		unset($this->cryptoKeyInterface);
64 64
 
65 65
 		$this->cryptoKeyInterface = new $type_fqcn([
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 			'public' => !empty($public_hex) ? sodium_hex2bin($public_hex) : null,
68 68
 		]);
69 69
 
70
-		if($secret_hex !== null){
70
+		if ($secret_hex !== null) {
71 71
 			sodium_memzero($secret_hex);
72 72
 		}
73 73
 
74
-		if($public_hex !== null){
74
+		if ($public_hex !== null) {
75 75
 			sodium_memzero($public_hex);
76 76
 		}
77 77
 
Please login to merge, or discard this patch.
src/Crypto/BoxKeypair.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-class BoxKeypair extends CryptoKeypair{
15
+class BoxKeypair extends CryptoKeypair {
16 16
 
17 17
 	/** @inheritdoc */
18 18
 	public function create(string &$seed_bin = null):CryptoKeyInterface{
19 19
 
20
-		if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES){
20
+		if ($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_BOX_SEEDBYTES) {
21 21
 			throw new CryptoException('invalid seed length');
22 22
 		}
23 23
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 		sodium_memzero($keypair);
33 33
 
34
-		if($seed_bin !== null){
34
+		if ($seed_bin !== null) {
35 35
 			sodium_memzero($seed_bin);
36 36
 		}
37 37
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function createFromSecret(string &$secret_bin):CryptoKeyInterface{
48 48
 
49
-		if(strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES){
49
+		if (strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES) {
50 50
 			throw new CryptoException('invalid secret key length');
51 51
 		}
52 52
 
Please login to merge, or discard this patch.
src/Crypto/SignedMessage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Traits\Crypto;
14 14
 
15
-class SignedMessage extends CryptoBox{
15
+class SignedMessage extends CryptoBox {
16 16
 
17 17
 	/** @inheritdoc */
18 18
 	public function create(string &$message):CryptoBoxInterface{
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 		sodium_memzero($box_bin);
35 35
 
36
-		if($this->message === false){
36
+		if ($this->message === false) {
37 37
 			throw new CryptoException('invalid box'); // @codeCoverageIgnore
38 38
 		}
39 39
 
Please login to merge, or discard this patch.
src/ClassLoader.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use Exception, ReflectionClass;
16 16
 
17
-trait ClassLoader{
17
+trait ClassLoader {
18 18
 
19 19
 	/**
20 20
 	 * Instances an object of $class/$type with an arbitrary number of $params
@@ -27,45 +27,45 @@  discard block
 block discarded – undo
27 27
 	 * @return mixed of type $type
28 28
 	 * @throws \Exception
29 29
 	 */
30
-	public function loadClass(string $class, string $type = null, ...$params){
30
+	public function loadClass(string $class, string $type = null, ...$params) {
31 31
 		$type = $type ?? $class;
32 32
 
33
-		try{
33
+		try {
34 34
 			$reflectionClass = new ReflectionClass($class);
35 35
 			$reflectionType  = new ReflectionClass($type);
36 36
 		}
37
-		catch(Exception $e){
37
+		catch (Exception $e) {
38 38
 			throw new TraitException('ClassLoader: '.$e->getMessage());
39 39
 		}
40 40
 
41 41
 
42
-		if($reflectionType->isTrait()){
42
+		if ($reflectionType->isTrait()) {
43 43
 			throw new TraitException($class.' cannot be an instance of trait '.$type);
44 44
 		}
45 45
 
46
-		if($reflectionClass->isAbstract()){
46
+		if ($reflectionClass->isAbstract()) {
47 47
 			throw new TraitException('cannot instance abstract class '.$class);
48 48
 		}
49 49
 
50
-		if($reflectionClass->isTrait()){
50
+		if ($reflectionClass->isTrait()) {
51 51
 			throw new TraitException('cannot instance trait '.$class);
52 52
 		}
53 53
 
54
-		if($class !== $type){
54
+		if ($class !== $type) {
55 55
 
56
-			if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){
56
+			if ($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)) {
57 57
 				throw new TraitException($class.' does not implement '.$type);
58 58
 			}
59
-			elseif(!$reflectionClass->isSubclassOf($type)) {
59
+			elseif (!$reflectionClass->isSubclassOf($type)) {
60 60
 				throw new TraitException($class.' does not inherit '.$type);
61 61
 			}
62 62
 
63 63
 		}
64 64
 
65
-		try{
65
+		try {
66 66
 			$object = $reflectionClass->newInstanceArgs($params);
67 67
 
68
-			if(!$object instanceof $type){
68
+			if (!$object instanceof $type) {
69 69
 				throw new TraitException('how did u even get here?'); // @codeCoverageIgnore
70 70
 			}
71 71
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		}
74 74
 		// @codeCoverageIgnoreStart
75 75
 		// here be dragons
76
-		catch(Exception $e){
76
+		catch (Exception $e) {
77 77
 			throw new TraitException('ClassLoader: '.$e->getMessage());
78 78
 		}
79 79
 		// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
 		try{
34 34
 			$reflectionClass = new ReflectionClass($class);
35 35
 			$reflectionType  = new ReflectionClass($type);
36
-		}
37
-		catch(Exception $e){
36
+		} catch(Exception $e){
38 37
 			throw new TraitException('ClassLoader: '.$e->getMessage());
39 38
 		}
40 39
 
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
 
56 55
 			if($reflectionType->isInterface() && !$reflectionClass->implementsInterface($type)){
57 56
 				throw new TraitException($class.' does not implement '.$type);
58
-			}
59
-			elseif(!$reflectionClass->isSubclassOf($type)) {
57
+			} elseif(!$reflectionClass->isSubclassOf($type)) {
60 58
 				throw new TraitException($class.' does not inherit '.$type);
61 59
 			}
62 60
 
Please login to merge, or discard this patch.
src/ArrayHelpers/SearchableArray.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use ArrayIterator, ArrayObject, RecursiveArrayIterator, RecursiveIteratorIterator, Traversable;
16 16
 
17
-trait SearchableArray{
17
+trait SearchableArray {
18 18
 	use DotArray;
19 19
 
20 20
 	/**
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param array|object|\Traversable|\ArrayIterator|\ArrayObject|null $array
29 29
 	 */
30
-	public function __construct($array = null){
30
+	public function __construct($array = null) {
31 31
 
32
-		if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){
32
+		if (($array instanceof ArrayObject) || ($array instanceof ArrayIterator)) {
33 33
 			$this->array = $array->getArrayCopy();
34 34
 		}
35
-		elseif($array instanceof Traversable){
35
+		elseif ($array instanceof Traversable) {
36 36
 			$this->array = iterator_to_array($array);
37 37
 		}
38 38
 		// yields unexpected results with DotArray
39
-		elseif(gettype($array) === 'object'){
39
+		elseif (gettype($array) === 'object') {
40 40
 			$this->array = get_object_vars($array);
41 41
 		}
42
-		elseif(is_array($array)){
42
+		elseif (is_array($array)) {
43 43
 			$this->array = $array;
44 44
 		}
45 45
 
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return mixed
56 56
 	 */
57
-	public function searchByKey(string $dotKey){
57
+	public function searchByKey(string $dotKey) {
58 58
 
59
-		foreach($this->iterator as $v){
59
+		foreach ($this->iterator as $v) {
60 60
 
61
-			if($this->getPath() === $dotKey){
61
+			if ($this->getPath() === $dotKey) {
62 62
 				return $v;
63 63
 			}
64 64
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 
72 72
 		$matches = [];
73 73
 
74
-		foreach($this->iterator as $v){
74
+		foreach ($this->iterator as $v) {
75 75
 
76
-			if($v === $value){
76
+			if ($v === $value) {
77 77
 				$matches[$this->getPath()] = $value;
78 78
 			}
79 79
 
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function isset(string $dotKey):bool{
91 91
 
92
-		foreach($this->iterator as $v){
92
+		foreach ($this->iterator as $v) {
93 93
 
94
-			if($this->getPath() === $dotKey){
94
+			if ($this->getPath() === $dotKey) {
95 95
 				return true;
96 96
 			}
97 97
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,15 +31,13 @@
 block discarded – undo
31 31
 
32 32
 		if(($array instanceof ArrayObject) || ($array instanceof ArrayIterator)){
33 33
 			$this->array = $array->getArrayCopy();
34
-		}
35
-		elseif($array instanceof Traversable){
34
+		} elseif($array instanceof Traversable){
36 35
 			$this->array = iterator_to_array($array);
37 36
 		}
38 37
 		// yields unexpected results with DotArray
39 38
 		elseif(gettype($array) === 'object'){
40 39
 			$this->array = get_object_vars($array);
41
-		}
42
-		elseif(is_array($array)){
40
+		} elseif(is_array($array)){
43 41
 			$this->array = $array;
44 42
 		}
45 43
 
Please login to merge, or discard this patch.