diff --git a/system/encryption/autoload.php b/system/encryption/autoload.php index 2ea2739..3432eab 100644 --- a/system/encryption/autoload.php +++ b/system/encryption/autoload.php @@ -8,8 +8,13 @@ namespace Phacil\Framework; -/** @package Phacil\Framework */ -final class Encryption { +/** + * Encryption class for Phacil Framework + * @since 1.0.0 + * @api + * @package Phacil\Framework + */ +class Encryption { private $key; private $method; private $cipher; @@ -19,8 +24,8 @@ final class Encryption { * @param string $opensslCipher * @return void */ - function __construct($key, $opensslCipher = 'aes-128-cbc') { - $this->key = $this->hash($key); + function __construct($key = null, $opensslCipher = 'aes-128-cbc') { + if($key) $this->key = $this->hash($key); if(function_exists('openssl_encrypt')) { $this->method = 'openssl'; @@ -31,6 +36,10 @@ final class Encryption { } + public function setKey($key) { + $this->key = $this->hash($key); + } + /** * @param string $value * @return string|false diff --git a/system/image/autoload.php b/system/image/autoload.php index 6da22d1..bffe9b5 100644 --- a/system/image/autoload.php +++ b/system/image/autoload.php @@ -10,10 +10,27 @@ namespace Phacil\Framework; //use Exception; -/** @package Phacil\Framework */ -final class Image { +/** + * @since 1.0.1 + * @package Phacil\Framework + */ +class Image { + /** + * + * @var string + */ private $file; + + /** + * + * @var \GdImage|false|void + */ private $image; + + /** + * + * @var array + */ private $info; /** @@ -21,16 +38,24 @@ final class Image { * @return void * @throws Exception */ - public function __construct($file) { + public function __construct($file = null) { if(!extension_loaded('gd')){ - throw new \Exception("The image function requires GD extension on PHP!"); + throw new \Phacil\Framework\Exception\RuntimeException("The image function requires GD extension on PHP!"); + } + + if($file){ + if ($this->infoChk($file)) + $this->image = $this->create($file); + else + throw new \Phacil\Framework\Exception('Error: Could not load image ' . $file . '!'); } + } - if($this->infoChk($file)) + public function setImage($file){ + if ($this->infoChk($file)) $this->image = $this->create($file); else - throw new \Exception('Error: Could not load image ' . $file . '!'); - + throw new \Phacil\Framework\Exception('Error: Could not load image ' . $file . '!'); } /**