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
44 changes: 44 additions & 0 deletions src/App/Enums/ExceptionMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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\App\Enums;

/**
* Class ExceptionMessages
* @package Quantum\App
*/
class ExceptionMessages
{
const APP_KEY_MISSING = 'APP KEY is missing.';

const EXECUTION_TERMINATED = 'Execution was terminated.';

const METHOD_NOT_SUPPORTED = 'The method `{%1}` is not supported for `{%2}`.';

const ADAPTER_NOT_SUPPORTED = 'The adapter `{%1}` is not supported.';

const DRIVER_NOT_SUPPORTED = 'The driver `{%1}` is not supported.';

const FILE_NOT_FOUND = 'The file `{%1}` not found.';

const NOT_FOUND = '{%1} `{%2}` not found.';

const NOT_INSTANCE_OF = 'The `{%1}` is not instance of `{%2}`.';

const CANT_CONNECT = 'Can not connect to `{%1}`.';

const MISSING_CONFIG = 'Could not load config `{%1}` properly.';

const UNAVAILABLE_REQUEST_METHOD = 'Provided request method `{%1}` is not available.';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* @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\App\Constants;
namespace Quantum\App\Enums;

/**
* Class ReservedKeys
Expand Down
6 changes: 4 additions & 2 deletions src/App/Exceptions/AppException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
* @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\App\Exceptions;

use Quantum\App\Enums\ExceptionMessages;

/**
* Class AppException
* @package Quantum\App
Expand All @@ -26,6 +28,6 @@ class AppException extends BaseException
*/
public static function missingAppKey(): AppException
{
return new static(t('exception.app_key_missing'), E_ERROR);
return new static(ExceptionMessages::APP_KEY_MISSING, E_ERROR);
}
}
74 changes: 69 additions & 5 deletions src/App/Exceptions/BaseException.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.7
* @since 2.9.9
*/

namespace Quantum\App\Exceptions;

use Quantum\App\Enums\ExceptionMessages;
use Exception;

/**
Expand All @@ -31,7 +32,7 @@ class BaseException extends Exception
public static function methodNotSupported(string $methodName, string $className): self
{
return new static(
"The method `$methodName` is not supported for `$className`",
_message(ExceptionMessages::METHOD_NOT_SUPPORTED, [$methodName, $className]),
E_WARNING
);
}
Expand All @@ -43,7 +44,7 @@ public static function methodNotSupported(string $methodName, string $className)
public static function adapterNotSupported(string $name): self
{
return new static(
"The adapter `$name` is not supported`",
_message(ExceptionMessages::ADAPTER_NOT_SUPPORTED, [$name]),
E_ERROR
);
}
Expand All @@ -55,7 +56,7 @@ public static function adapterNotSupported(string $name): self
public static function driverNotSupported(string $name): self
{
return new static(
"The driver `$name` is not supported",
_message(ExceptionMessages::DRIVER_NOT_SUPPORTED, [$name]),
E_ERROR
);
}
Expand All @@ -67,8 +68,71 @@ public static function driverNotSupported(string $name): self
public static function fileNotFound(string $name): self
{
return new static(
"The file `$name` not found",
_message(ExceptionMessages::FILE_NOT_FOUND, [$name]),
E_ERROR
);
}

/**
* @param string $subject
* @param string $name
* @return self
*/
public static function notFound(string $subject, string $name): self
{
return new static(
_message(ExceptionMessages::NOT_FOUND, [$subject, $name]),
E_ERROR
);
}

/**
* @param string $instance
* @param string $name
* @return self
*/
public static function notInstanceOf(string $instance, string $name): self
{
return new static(
_message(ExceptionMessages::NOT_INSTANCE_OF, [$instance, $name]),
E_ERROR
);
}

/**
* @param string $name
* @return self
*/
public static function cantConnect(string $name): self
{
return new static(
_message(ExceptionMessages::CANT_CONNECT, [$name]),
E_ERROR
);
}

/**
* @param string $name
* @return self
*/

public static function missingConfig(string $name): self
{
return new static(
_message(ExceptionMessages::MISSING_CONFIG, $name),
E_ERROR
);
}

/**
* @param string $name
* @return self
*/
public static function requestMethodNotAvailable(string $name): self
{
return new static(
_message(ExceptionMessages::UNAVAILABLE_REQUEST_METHOD, [$name]),
E_WARNING
);
}
}
7 changes: 5 additions & 2 deletions src/App/Exceptions/StopExecutionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@
* @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\App\Exceptions;

use Quantum\App\Enums\ExceptionMessages;

/**
* Class StopExecutionException
* @package Quantum\App
*/
class StopExecutionException extends BaseException
{

/**
* @param int|null $code
* @return StopExecutionException
*/
public static function executionTerminated(?int $code): StopExecutionException
{
return new static(t('exception.execution_terminated'), $code);
return new static(ExceptionMessages::EXECUTION_TERMINATED, $code);
}
}
4 changes: 2 additions & 2 deletions src/Config/Config.php
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.7
* @since 2.9.9
*/

namespace Quantum\Config;
Expand All @@ -25,7 +25,7 @@

/**
* Class Config
* @package Quantum\Libraries\Config
* @package Quantum\Config
*/
class Config implements StorageInterface
{
Expand Down
26 changes: 26 additions & 0 deletions src/Config/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\Config\Enums;

use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages;

/**
* Class ExceptionMessages
* @package Quantum\Config
*/
final class ExceptionMessages extends BaseExceptionMessages
{
const CONFIG_COLLISION = 'Config key `{%1}` is already in use';
}
14 changes: 4 additions & 10 deletions src/Config/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,27 @@
* @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\Config\Exceptions;

use Quantum\Config\Enums\ExceptionMessages;
use Quantum\App\Exceptions\BaseException;

/**
* Class ConfigException
* @package Quantum\Libraries\Config
* @package Quantum\Config
*/
class ConfigException extends BaseException
{
/**
* @return ConfigException
*/
public static function configAlreadyLoaded(): ConfigException
{
return new static(t('exception.config_already_loaded'), E_WARNING);
}

/**
* @param string $name
* @return ConfigException
*/
public static function configCollision(string $name): ConfigException
{
return new static('Config key `' . $name . '` is already in use', E_WARNING);
return new static(_message(ExceptionMessages::CONFIG_COLLISION, [$name]), E_WARNING);
}
}
35 changes: 35 additions & 0 deletions src/Di/Enums/ExceptionMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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\Di\Enums;

use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages;

/**
* Class ExceptionMessages
* @package Quantum\Di
*/
final class ExceptionMessages extends BaseExceptionMessages
{

const DEPENDENCY_NOT_REGISTERED = 'The dependency `{%1}` is not registered.';

const DEPENDENCY_ALREADY_REGISTERED = 'The dependency `{%1}` is already registered.';

const DEPENDENCY_NOT_INSTANTIABLE = 'The dependency `{%1}` is not instantiable.';

const INVALID_ABSTRACT_DEPENDENCY = 'The dependency `{%1}` is not valid abstract class.';

const CIRCULAR_DEPENDENCY = 'Circular dependency detected: `{%1}`';
}
Loading