Fix phpstan issues

This commit is contained in:
sephster
2019-07-01 19:17:43 +01:00
parent 7bc1ec643e
commit c4c354e2df
15 changed files with 79 additions and 46 deletions

View File

@@ -19,7 +19,7 @@ use LogicException;
trait CryptTrait
{
/**
* @var string|Key
* @var string|Key|null
*/
protected $encryptionKey;
@@ -39,9 +39,13 @@ trait CryptTrait
return Crypto::encrypt($unencryptedData, $this->encryptionKey);
}
return Crypto::encryptWithPassword($unencryptedData, $this->encryptionKey);
if (is_string($this->encryptionKey)) {
return Crypto::encryptWithPassword($unencryptedData, $this->encryptionKey);
}
throw new LogicException('Encryption key not set when attempting to encrypt');
} catch (Exception $e) {
throw new LogicException($e->getMessage(), null, $e);
throw new LogicException($e->getMessage(), 0, $e);
}
}
@@ -61,9 +65,13 @@ trait CryptTrait
return Crypto::decrypt($encryptedData, $this->encryptionKey);
}
return Crypto::decryptWithPassword($encryptedData, $this->encryptionKey);
if (is_string($this->encryptionKey)) {
return Crypto::decryptWithPassword($encryptedData, $this->encryptionKey);
}
throw new LogicException('Encryption key not set when attempting to decrypt');
} catch (Exception $e) {
throw new LogicException($e->getMessage(), null, $e);
throw new LogicException($e->getMessage(), 0, $e);
}
}