Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/Console/Commands/DebugBarCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

namespace Quantum\Console\Commands;

use Quantum\Libraries\Storage\Exceptions\FileSystemException;
use Quantum\Libraries\Storage\Factories\FileSystemFactory;
use Quantum\Libraries\Lang\Exceptions\LangException;
use Quantum\Config\Exceptions\ConfigException;
use Quantum\App\Exceptions\BaseException;
use Quantum\Libraries\Storage\FileSystem;
use Quantum\Di\Exceptions\DiException;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class DebugBarAssetsCommand
Expand Down Expand Up @@ -64,8 +67,11 @@ class DebugBarCommand extends QtCommand

/**
* Executes the command and publishes the debug bar assets
* @throws LangException
* @throws BaseException
* @throws FileSystemException
* @throws ConfigException
* @throws DiException
* @throws ReflectionException
*/
public function exec()
{
Expand All @@ -85,15 +91,16 @@ public function exec()
* Recursively copies the debug bar assets
* @param string $src
* @param string $dst
* @throws LangException
* @return void
* @throws FileSystemException
*/
private function copyResources(string $src, string $dst)
{
$dir = opendir($src);

if ($dst != $this->publicDebugBarFolderPath) {
if ($this->fs->makeDirectory($dst) === false) {
throw new \RuntimeException(t('exception.directory_cant_be_created', $dst));
throw FileSystemException::directoryNotWritable($dst);
}
}

Expand All @@ -111,4 +118,4 @@ private function copyResources(string $src, string $dst)
closedir($dir);
}
}
}
}
12 changes: 7 additions & 5 deletions src/Libraries/Cache/Adapters/DatabaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace Quantum\Libraries\Cache\Adapters;

use Quantum\Libraries\Cache\Enums\ExceptionMessages;
use Quantum\Model\Factories\ModelFactory;
use Psr\SimpleCache\CacheInterface;
use InvalidArgumentException;
Expand Down Expand Up @@ -73,11 +74,12 @@ public function get($key, $default = null)

/**
* @inheritDoc
* @throws InvalidArgumentException
*/
public function getMultiple($keys, $default = null)
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$keys')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$keys'), E_WARNING);
}

$result = [];
Expand Down Expand Up @@ -133,7 +135,7 @@ public function set($key, $value, $ttl = null): bool
public function setMultiple($values, $ttl = null): bool
{
if (!is_array($values)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -166,7 +168,7 @@ public function delete($key): bool
public function deleteMultiple($keys): bool
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$keys')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$keys'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -195,4 +197,4 @@ private function keyHash(string $key): string
{
return sha1($this->prefix . $key);
}
}
}
18 changes: 13 additions & 5 deletions src/Libraries/Cache/Adapters/FileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

namespace Quantum\Libraries\Cache\Adapters;

use Quantum\Libraries\Storage\Factories\FileSystemFactory;
use Quantum\Libraries\Cache\Enums\ExceptionMessages;
use Quantum\Config\Exceptions\ConfigException;
use Quantum\App\Exceptions\BaseException;
use Quantum\Libraries\Storage\FileSystem;
use Quantum\Di\Exceptions\DiException;
use Psr\SimpleCache\CacheInterface;
use InvalidArgumentException;
use ReflectionException;

/**
* Class FileAdapter
Expand Down Expand Up @@ -50,6 +54,9 @@ class FileAdapter implements CacheInterface
/**
* @param array $params
* @throws BaseException
* @throws ConfigException
* @throws DiException
* @throws ReflectionException
*/
public function __construct(array $params)
{
Expand Down Expand Up @@ -84,11 +91,12 @@ public function get($key, $default = null)

/**
* @inheritDoc
* @throws InvalidArgumentException
*/
public function getMultiple($keys, $default = null)
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$keys')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$keys'), E_WARNING);
}

$result = [];
Expand Down Expand Up @@ -134,7 +142,7 @@ public function set($key, $value, $ttl = null)
public function setMultiple($values, $ttl = null): bool
{
if (!is_array($values)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -167,7 +175,7 @@ public function delete($key)
public function deleteMultiple($keys): bool
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$keys')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$keys'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -210,4 +218,4 @@ private function getPath(string $key): string
{
return $this->cacheDir . DS . sha1($this->prefix . $key);
}
}
}
10 changes: 6 additions & 4 deletions src/Libraries/Cache/Adapters/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Quantum\Libraries\Cache\Adapters;

use Quantum\Libraries\Cache\Exceptions\CacheException;
use Quantum\Libraries\Cache\Enums\ExceptionMessages;
use Quantum\App\Exceptions\BaseException;
use Psr\SimpleCache\CacheInterface;
use InvalidArgumentException;
Expand Down Expand Up @@ -81,11 +82,12 @@ public function get($key, $default = null)

/**
* @inheritDoc
* @throws InvalidArgumentException
*/
public function getMultiple($keys, $default = null)
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$result = [];
Expand Down Expand Up @@ -126,7 +128,7 @@ public function set($key, $value, $ttl = null): bool
public function setMultiple($values, $ttl = null): bool
{
if (!is_array($values)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand All @@ -153,7 +155,7 @@ public function delete($key): bool
public function deleteMultiple($keys): bool
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -182,4 +184,4 @@ private function keyHash(string $key): string
{
return sha1($this->prefix . $key);
}
}
}
12 changes: 7 additions & 5 deletions src/Libraries/Cache/Adapters/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.5
* @since 2.9.9
*/

namespace Quantum\Libraries\Cache\Adapters;

use Quantum\Libraries\Cache\Enums\ExceptionMessages;
use Psr\SimpleCache\CacheInterface;
use InvalidArgumentException;
use RedisException;
Expand Down Expand Up @@ -76,11 +77,12 @@ public function get($key, $default = null)

/**
* @inheritDoc
* @throws InvalidArgumentException
*/
public function getMultiple($keys, $default = null)
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$result = [];
Expand Down Expand Up @@ -128,7 +130,7 @@ public function set($key, $value, $ttl = null)
public function setMultiple($values, $ttl = null): bool
{
if (!is_array($values)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand All @@ -155,7 +157,7 @@ public function delete($key): bool
public function deleteMultiple($keys): bool
{
if (!is_array($keys)) {
throw new InvalidArgumentException(t(_message('exception.non_iterable_value', '$values')), E_WARNING);
throw new InvalidArgumentException(_message(ExceptionMessages::ARGUMENT_NOT_ITERABLE, '$values'), E_WARNING);
}

$results = [];
Expand Down Expand Up @@ -185,4 +187,4 @@ private function keyHash(string $key): string
{
return sha1($this->prefix . $key);
}
}
}
26 changes: 26 additions & 0 deletions src/Libraries/Cache/Enums/ExceptionMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Quantum PHP Framework
*
* An open source software development framework for PHP
*
* @package Quantum
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
*/

namespace Quantum\Libraries\Cache\Enums;

use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages;

/**
* Class ExceptionMessages
* @package Quantum\Libraries\Cache
*/
final class ExceptionMessages extends BaseExceptionMessages
{
const ARGUMENT_NOT_ITERABLE = 'The argument {%1} is not iterable';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace {{MODULE_NAMESPACE}}\Controllers;
Expand Down Expand Up @@ -66,7 +66,7 @@ class AccountController extends BaseController
} catch (AuthException $e) {
$response->json([
'status' => self::STATUS_ERROR,
'message' => t('exception.execution_terminated')
'message' => $e->getMessage()
]);
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ class AccountController extends BaseController
} catch (AuthException $e) {
$response->json([
'status' => self::STATUS_ERROR,
'message' => t('exception.execution_terminated')
'message' => $e->getMessage()
]);
}
}
Expand Down