Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c0c932d
Updating some of the dependencies and setting the php minimum version…
Dec 15, 2021
f5f76aa
Updating php version on travis
Dec 15, 2021
549927d
Updating the code according to new version of the package dotenv to ^4.2
Dec 15, 2021
1315e21
Update the code according to new version of the package dflydev-dot-a…
Dec 15, 2021
9fbce50
Logic improvement of Database, Model and DBAL
Dec 15, 2021
c78f0ff
Improving the Idiorm DBAL and adding new having() method
Dec 15, 2021
4640adb
Updating Idiorm DBAL unit tests according new changes
Dec 15, 2021
f8f360e
More changes on Idiorm DBAL (segregating the interface and adding new…
Dec 15, 2021
c74ffec
SleekDB full integration
Dec 15, 2021
1c06878
SleekDB DBAL unit testing
Dec 15, 2021
851a0db
Removing unnecessary declaration
Dec 15, 2021
bddae71
Keeping the base/store directory
Dec 15, 2021
0684486
Correcting doc blocks for Auth
Dec 17, 2021
0fc2d49
Updating the unit tests according to composer autoload rule
Dec 17, 2021
d0d45ce
Correcting unit tests
Dec 17, 2021
c0268b3
Correcting the unit tests
Dec 17, 2021
0d54841
Correcting the unit tests
Dec 17, 2021
4439c9d
Updating the phpunit version
Dec 17, 2021
97ccb05
Correcting the deprecated way of getting the type
Dec 20, 2021
38a97dc
Updating the dependency version
Dec 20, 2021
cab48b2
Updating the algorithm constant types from integer to string accordin…
Dec 21, 2021
41d5639
Correcting the deprecated way of getting the type
Dec 21, 2021
9342266
Removing redundant operation
Dec 21, 2021
a4da282
Correcting doc-block declarations
Dec 21, 2021
6f5ac1b
Correcting arguments and argument types
Dec 21, 2021
9d8f5e4
Correctly checking the arrays
Dec 21, 2021
e7a1089
Removing unnecessary variable and correcting the typo
Dec 21, 2021
cdcca0c
Making sure to always return array
Dec 21, 2021
e14c34b
Di add() method and unit test updates
Dec 26, 2021
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php
php:
- 7.2
- 7.3
- 7.4

before_install:
- sudo apt-get update -qq
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,33 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.3",
"ext-simplexml": "*",
"j4mie/paris": "^1.5",
"firebase/php-jwt": "^5.0",
"gumlet/php-image-resize": "^1.9",
"gumlet/php-image-resize": "^2.0",
"symfony/var-dumper": "^4.2",
"symfony/var-exporter": "^5.2",
"symfony/console": "^4.3",
"vlucas/phpdotenv": "^2.4",
"vlucas/phpdotenv": "^4.2",
"dflydev/dot-access-data": "^3.0",
"maximebf/debugbar": "^1.15",
"phpmailer/phpmailer": "^6.0",
"twig/twig": "^2.7",
"php-curl-class/php-curl-class": "^8.6",
"gerardbalaoro/figlet-php": "^1.0",
"psr/log": "^1.1"
"psr/log": "^1.1",
"rakibtg/sleekdb": "^2.13"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.2"
"phpunit/phpunit": "^8.2",
"mockery/mockery": "^1.4",
"mikey179/vfsstream": "^1.6"
},
"autoload": {
"psr-4": {
"Quantum\\": "src/"
"Quantum\\": "src/",
"Quantum\\Tests\\": "tests/unit/"
}
},
"minimum-stability": "dev",
Expand Down
20 changes: 14 additions & 6 deletions src/Di/Di.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.5.0
* @since 2.6.0
*/

namespace Quantum\Di;
Expand Down Expand Up @@ -65,22 +65,30 @@ public static function autowire(callable $entry, array $additional = []): array
$params = [];

foreach ($reflection->getParameters() as $param) {
$type = $param->getType();
$type = $param->getType()->getName();

if (!$type || !self::instantiable($type)) {
array_push($params, current($additional));
next($additional);
continue;
}

$dependency = $param->getType();

array_push($params, self::get($dependency));
array_push($params, self::get($type));
}

return $params;
}

/**
* Adds new dependecy
* @param string $dependency
*/
public static function add(string $dependency) {
if(!in_array($dependency, self::$dependencies) && class_exists($dependency)) {
array_push(self::$dependencies, $dependency);
}
}

/**
* Gets the dependency from the container
* @param string $dependency
Expand Down Expand Up @@ -116,7 +124,7 @@ protected static function instantiate(string $dependency)

if ($constructor) {
foreach ($constructor->getParameters() as $param) {
$type = (string) $param->getType();
$type = $param->getType()->getName();

if (!$type || !self::instantiable($type)) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/Environment/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function load(Setup $setup): Environment
throw EnvException::fileNotFound();
}

$this->envContent = (new Dotenv(base_dir(), $this->envFile))->load();
$this->envContent = Dotenv::createMutable(base_dir(), $this->envFile)->load();

return $this;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public function updateRow(string $key, ?string $value)
$this->fs->append($envFilePath, $key . "=" . $value . PHP_EOL);
}

$this->envContent = (new Dotenv(base_dir(), $this->envFile))->overload();
$this->envContent = Dotenv::createMutable(base_dir(), $this->envFile)->load();
}

/**
Expand Down
42 changes: 40 additions & 2 deletions src/Exceptions/DatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,37 @@ class DatabaseException extends \Exception
/**
* Config file not found message
*/
const CONFIG_FILE_NOT_FOUND = 'Config file `{%1}` does not exists';
const CONFIG_NOT_PROVIDED = 'Configuration does not provided';

/**
* ORM class not defined message
*/
const ORM_CLASS_NOT_DEFINED = 'Missing ORM defination in config file';
const ORM_CLASS_NOT_DEFINED = 'Missing ORM definition in config file';

/**
* Orm class not found message
*/
const ORM_CLASS_NOT_FOUND = 'ORM `{%1}` class not found';

/**
* Method not supported message
*/
const NOT_SUPPORTED_METHOD = 'The method `{%1}` is not supported for ORM `{%2}`';

/**
* Method not supported message
*/
const NOT_SUPPORTED_OPERATOR = 'The operator `{%1}` is not supported';


/**
* @return \Quantum\Exceptions\DatabaseException
*/
public static function missingConfig(): DatabaseException
{
return new static(self::CONFIG_NOT_PROVIDED, E_ERROR);
}

/**
* @return \Quantum\Exceptions\DatabaseException
*/
Expand All @@ -64,4 +83,23 @@ public static function ormClassNotFound(string $name): DatabaseException
{
return new static(_message(self::ORM_CLASS_NOT_FOUND, $name), E_ERROR);
}

/**
* @param string $methodName
* @param string $ormName
* @return \Quantum\Exceptions\DatabaseException
*/
public static function methodNotSupported(string $methodName, string $ormName): DatabaseException
{
return new static(_message(self::NOT_SUPPORTED_METHOD, [$methodName, $ormName]), E_WARNING);
}

/**
* @param string $operator
* @return \Quantum\Exceptions\DatabaseException
*/
public static function operatorNotSupported(string $operator): DatabaseException
{
return new static(_message(self::NOT_SUPPORTED_OPERATOR, [$operator]), E_WARNING);
}
}
2 changes: 1 addition & 1 deletion src/Factory/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function get(string $modelClass): QtModel
config()->import(new Setup('config', 'database', true));
}

$model->setOrm(Database::getInstance()->getOrm($model->table, $model->idColumn));
$model->setOrm(Database::getInstance()->getOrm($model->table, $model->idColumn, $model->foreignKeys ?? []));

return $model;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Class Request
* @package Quantum\Http
* @method static void init(Server $server)

* @method static void create(string $method, string $url, array $data = null, array $file = null)
* @method static void flush()
* @method static string|null getMethod()
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Request/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ trait Params

/**
* Gets the GET params
* @return array|null
* @return array
*/
private static function getParams(): ?array
private static function getParams(): array
{
$getParams = [];

if (!empty($_GET)) {
$getParams = filter_input_array(INPUT_GET, FILTER_DEFAULT);
$getParams = filter_input_array(INPUT_GET, FILTER_DEFAULT) ?: [] ;
}

return $getParams;
}

/**
* Gets the POST params
* @return array|null
* @return array
*/
private static function postParams(): ?array
private static function postParams(): array
{
$postParams = [];

if (!empty($_POST)) {
$postParams = filter_input_array(INPUT_POST, FILTER_DEFAULT);
$postParams = filter_input_array(INPUT_POST, FILTER_DEFAULT) ?: [];
}

return $postParams;
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Asset/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function url(string $path): string
*/
private function publish()
{
if ($this->storage) {
if (!empty($this->storage)) {
foreach ($this->storage as $asset) {
if ($asset->getPosition() != -1) {
if (isset($this->published[$asset->getType()][$asset->getPosition()])) {
Expand Down
8 changes: 6 additions & 2 deletions src/Libraries/Auth/ApiAuth.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.5.0
* @since 2.6.0
*/

namespace Quantum\Libraries\Auth;
Expand Down Expand Up @@ -79,6 +79,7 @@ public static function getInstance(AuthServiceInterface $authService, Mailer $ma
* @throws \PHPMailer\PHPMailer\Exception
* @throws \Quantum\Exceptions\AuthException
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\JwtException
* @throws \ReflectionException
*/
public function signin(string $username, string $password)
Expand Down Expand Up @@ -125,6 +126,7 @@ public function signout(): bool
/**
* User
* @return \Quantum\Libraries\Auth\User|null
* @throws \Quantum\Exceptions\JwtException
*/
public function user(): ?User
{
Expand All @@ -149,6 +151,7 @@ public function user(): ?User
* Get Updated Tokens
* @param \Quantum\Libraries\Auth\User $user
* @return array
* @throws \Quantum\Exceptions\JwtException
*/
public function getUpdatedTokens(User $user): array
{
Expand Down Expand Up @@ -183,7 +186,8 @@ protected function checkRefreshToken(): ?User
/**
* Set Updated Tokens
* @param \Quantum\Libraries\Auth\User $user
* @return array Tokens
* @return array
* @throws \Quantum\Exceptions\JwtException
*/
protected function setUpdatedTokens(User $user): array
{
Expand Down
8 changes: 5 additions & 3 deletions src/Libraries/Auth/BaseAuth.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.4.0
* @since 2.6.0
*/

namespace Quantum\Libraries\Auth;
Expand Down Expand Up @@ -102,7 +102,7 @@ abstract class BaseAuth
/**
* @var int
*/
protected $otpLenght = 6;
protected $otpLength = 6;

/**
* @var array
Expand Down Expand Up @@ -318,10 +318,11 @@ protected function getUser(string $username, string $password): User
* @throws \PHPMailer\PHPMailer\Exception
* @throws \Quantum\Exceptions\DiException
* @throws \ReflectionException
* @throws \Exception
*/
protected function twoStepVerification(User $user): string
{
$otp = random_number($this->otpLenght);
$otp = random_number($this->otpLength);

$otpToken = $this->generateToken($user->getFieldValue($this->keyFields[self::USERNAME_KEY]));

Expand Down Expand Up @@ -358,6 +359,7 @@ protected function twoStepVerification(User $user): string
* @param string $otpToken
* @return \Quantum\Libraries\Auth\User
* @throws \Quantum\Exceptions\AuthException
* @throws \Exception
*/
protected function verifyAndUpdateOtp(int $otp, string $otpToken): User
{
Expand Down
10 changes: 9 additions & 1 deletion src/Libraries/Auth/WebAuth.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.5.0
* @since 2.6.0
*/

namespace Quantum\Libraries\Auth;
Expand Down Expand Up @@ -74,7 +74,9 @@ public static function getInstance(AuthServiceInterface $authService, Mailer $ma
* @throws \PHPMailer\PHPMailer\Exception
* @throws \Quantum\Exceptions\AuthException
* @throws \Quantum\Exceptions\CryptorException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\SessionException
* @throws \ReflectionException
*/
public function signin(string $username, string $password, bool $remember = false)
Expand All @@ -96,6 +98,8 @@ public function signin(string $username, string $password, bool $remember = fals
/**
* Sign Out
* @return bool
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\SessionException
*/
public function signout(): bool
{
Expand All @@ -113,6 +117,8 @@ public function signout(): bool
* User
* @return \Quantum\Libraries\Auth\User|null
* @throws \Quantum\Exceptions\CryptorException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\SessionException
*/
public function user(): ?User
{
Expand All @@ -137,6 +143,8 @@ public function user(): ?User
* @return bool
* @throws \Quantum\Exceptions\AuthException
* @throws \Quantum\Exceptions\CryptorException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\SessionException
*/
public function verifyOtp(int $otp, string $otpToken): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function all(): ?Data
*/
public function has(string $key): bool
{
return self::$configs && !empty(self::$configs->get($key));
return self::$configs && !empty(self::$configs->has($key));
}

/**
Expand Down
Loading