Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahram1995 committed May 19, 2023
2 parents abebbf4 + 210f5bb commit d85fb33
Show file tree
Hide file tree
Showing 55 changed files with 2,597 additions and 1,085 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"ext-json": "*",
"ext-simplexml": "*",
"ext-fileinfo": "*",
"ext-openssl": "*",
"ext-dom": "*",
"j4mie/paris": "^1.5",
"firebase/php-jwt": "^6.0",
"gumlet/php-image-resize": "^2.0",
Expand Down
16 changes: 6 additions & 10 deletions src/Bootstrap.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.8.0
* @since 2.9.0
*/

namespace Quantum;
Expand All @@ -25,6 +25,7 @@
use Quantum\Http\Response;
use Quantum\Http\Request;
use Quantum\Loader\Setup;
use ReflectionException;
use Psr\Log\LogLevel;
use Quantum\Di\Di;

Expand All @@ -40,26 +41,21 @@ class Bootstrap
* @throws Exceptions\ModuleLoaderException
* @throws Exceptions\ControllerException
* @throws Exceptions\MiddlewareException
* @throws Exceptions\DatabaseException
* @throws Exceptions\SessionException
* @throws Exceptions\ConfigException
* @throws Exceptions\RouteException
* @throws Exceptions\CsrfException
* @throws Exceptions\LangException
* @throws Exceptions\ViewException
* @throws Exceptions\DiException
* @throws \Twig\Error\RuntimeError
* @throws ReflectionException
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \ReflectionException
*/
public static function run()
{
try {
$request = Di::get(Request::class);
$response = Di::get(Response::class);

$request->init(new Server);
$request->init(Server::getInstance());
$response->init();

if ($request->getMethod() == 'OPTIONS') {
Expand Down Expand Up @@ -93,7 +89,7 @@ public static function run()
* @param Response $response
* @throws Exceptions\ConfigException
* @throws Exceptions\DiException
* @throws \ReflectionException
* @throws ReflectionException
*/
private static function handleCors(Response $response)
{
Expand Down
18 changes: 12 additions & 6 deletions src/Console/Commands/DebugBarCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.8.0
* @since 2.9.0
*/

namespace Quantum\Console\Commands;

use Quantum\Libraries\Storage\FileSystem;
use Quantum\Exceptions\LangException;
use Quantum\Exceptions\DiException;
use Quantum\Console\QtCommand;
use ReflectionException;
use Quantum\Di\Di;

/**
Expand Down Expand Up @@ -52,16 +55,19 @@ class DebugBarCommand extends QtCommand
* Path to public debug bar resources
* @var string
*/
private $publicDebugbarFolderPath = 'public/assets/DebugBar/Resources';
private $publicDebugBarFolderPath = 'public/assets/DebugBar/Resources';

/**
* Path to vendor debug bar resources
* @var string
*/
private $vendorDebugbarFolderPath = 'vendor/maximebf/debugbar/src/DebugBar/Resources';
private $vendorDebugBarFolderPath = 'vendor/maximebf/debugbar/src/DebugBar/Resources';

/**
* Executes the command and publishes the debug bar assets
* @throws LangException
* @throws DiException
* @throws ReflectionException
*/
public function exec()
{
Expand All @@ -72,7 +78,7 @@ public function exec()
return;
}

$this->copyResources($this->vendorDebugbarFolderPath, $this->publicDebugbarFolderPath);
$this->copyResources($this->vendorDebugBarFolderPath, $this->publicDebugBarFolderPath);

$this->info('Debugbar resources successfully published');
}
Expand All @@ -81,13 +87,13 @@ public function exec()
* Recursively copies the debug bar assets
* @param string $src
* @param string $dst
* @throws \Quantum\Exceptions\LangException
* @throws LangException
*/
private function copyResources(string $src, string $dst)
{
$dir = opendir($src);

if ($dst != $this->publicDebugbarFolderPath) {
if ($dst != $this->publicDebugBarFolderPath) {
if ($this->fs->makeDirectory($dst) === false) {
throw new \RuntimeException(t('exception.directory_cant_be_created', $dst));
}
Expand Down
19 changes: 11 additions & 8 deletions src/Console/Commands/KeyGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.8.0
* @since 2.9.0
*/

namespace Quantum\Console\Commands;

use Quantum\Environment\Environment;
use Quantum\Exceptions\EnvException;
use Quantum\Exceptions\DiException;
use Quantum\Console\QtCommand;
use Quantum\Loader\Setup;
use ReflectionException;
use Exception;

/**
* Class KeyGenerateCommand
Expand Down Expand Up @@ -54,10 +57,10 @@ class KeyGenerateCommand extends QtCommand

/**
* Executes the command and stores the generated key to .env file
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\EnvException
* @throws \ReflectionException
* @throws \Exception
* @throws DiException
* @throws EnvException
* @throws ReflectionException
* @throws Exception
*/
public function exec()
{
Expand All @@ -78,11 +81,11 @@ public function exec()
/**
* Generates random string
* @return string
* @throws \Exception
* @throws Exception
*/
private function generateRandomKey(): string
{
return base64_encode(random_bytes((int)$this->getOption('length')));
return bin2hex(random_bytes((int)$this->getOption('length')));
}

}
1 change: 0 additions & 1 deletion src/Console/Commands/MigrationGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class MigrationGenerateCommand extends QtCommand

/**
* Executes the command
* @throws \Quantum\Exceptions\LangException
* @throws \Quantum\Exceptions\MigrationException
*/
public function exec()
Expand Down
20 changes: 13 additions & 7 deletions src/Console/Commands/MigrationMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +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.8.0
* @since 2.9.0
*/

namespace Quantum\Console\Commands;

use Quantum\Exceptions\MigrationException;
use Quantum\Exceptions\DatabaseException;
use Quantum\Exceptions\ConfigException;
use Quantum\Migration\MigrationManager;
use Quantum\Exceptions\LangException;
use Quantum\Exceptions\AppException;
use Quantum\Exceptions\DiException;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class MigrationMigrateCommand
Expand Down Expand Up @@ -55,12 +61,12 @@ class MigrationMigrateCommand extends QtCommand

/**
* Executes the command
* @throws \Quantum\Exceptions\AppException
* @throws \Quantum\Exceptions\ConfigException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\LangException
* @throws \ReflectionException
* @throws AppException
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws LangException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
20 changes: 18 additions & 2 deletions src/Environment/Server.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.0.0
* @since 2.9.0
*/

namespace Quantum\Environment;
Expand All @@ -26,14 +26,30 @@ class Server
*/
private $server = [];


private static $instance = null;

/**
* Server constructor.
*/
public function __construct()
private function __construct()
{
$this->server = $_SERVER ?? [];
}

/**
* Get Instance
* @return Server|null
*/
public static function getInstance(): ?Server
{
if (self::$instance === null) {
self::$instance = new self();
}

return self::$instance;
}

/**
* @return array
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Exceptions/FileSystemException.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public static function directoryNotWritable(string $name): FileSystemException
return new static(t('exception.directory_not_writable', $name), E_WARNING);
}

/**
* @param string $name
* @return FileSystemException
* @throws LangException
*/
public static function fileNotFound(string $name): FileSystemException
{
return new static(t('exception.file_not_found', $name), E_WARNING);
}

/**
* @return FileSystemException
* @throws LangException
Expand Down
34 changes: 34 additions & 0 deletions src/Exceptions/MailerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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.0
*/

namespace Quantum\Exceptions;

/**
* Class MailerException
* @package Quantum\Exceptions
*/
class MailerException extends \Exception
{

/**
* @param string $name
* @return MailerException
* @throws LangException
*/
public static function unsupportedAdapter(string $name): MailerException
{
return new static(t('exception.adapter_not_supported', $name), E_WARNING);
}

}

0 comments on commit d85fb33

Please sign in to comment.