Skip to content

Commit

Permalink
dependencies updated
Browse files Browse the repository at this point in the history
  • Loading branch information
s3b4stian committed Oct 3, 2022
1 parent f495fa0 commit db8ffc0
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 126 deletions.
5 changes: 4 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
'@PSR12' => true,
'no_whitespace_in_blank_line' => true,
'return_type_declaration' => true,
'native_function_invocation' => ['include' => ['@all']],
'native_function_invocation' => ['include' => ['@compiler_optimized']],
'phpdoc_align' => true,
'phpdoc_separation' => true,
'phpdoc_line_span' => ['property' => 'single', 'const' => 'single']
])
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<a href="#"><img src="logo-linna-96.png" alt="Linna Logo"></a>
<a href="#"><img src="logo-linna-128.png" alt="Linna Logo"></a>
</div>

<br/>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"ext-mysqli": "*"
},
"require-dev": {
"infection/infection": "^0.21",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^9.0",
"linna/framework": "dev-master",
"infection/infection": ">=0.26",
"phpstan/phpstan": ">=1.8",
"phpunit/phpunit": ">=9.0",
"linna/framework": "^0.27.0",
"linna/db-dumps": "dev-master",
"linna/auth-mapper-test-trait": "dev-master"
},
Expand Down
Binary file added logo-linna-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed logo-linna-96.png
Binary file not shown.
25 changes: 0 additions & 25 deletions phpunit.local.xml

This file was deleted.

43 changes: 20 additions & 23 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.0/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true">
<testsuites>
<testsuite name="Linna Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
<php>
<var name="pdo_mysql_dsn" value="mysql:host=0.0.0.0;dbname=linna_db;charset=utf8mb4"/>
<var name="pdo_mysql_user" value="root" />
<var name="pdo_mysql_password" value="password" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php" verbose="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Linna Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<var name="pdo_mysql_dsn" value="mysql:host=0.0.0.0;dbname=linna_db;charset=utf8mb4"/>
<var name="pdo_mysql_user" value="root"/>
<var name="pdo_mysql_password" value="password"/>
</php>
</phpunit>
25 changes: 13 additions & 12 deletions src/Linna/Authentication/EnhancedAuthenticationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@
*/
class EnhancedAuthenticationMapper extends MapperAbstract implements EnhancedAuthenticationMapperInterface
{
/**
* @var ExtendedPDO Database Connection
*/
/** @var ExtendedPDO Database Connection */
protected ExtendedPDO $pdo;

/**
* @var string Constant part of SELECT query
*/
/** @var string Constant part of SELECT query */
protected string $baseQuery = 'SELECT login_attempt_id AS id, user_name AS userName, session_id AS sessionId, ip, date_time AS "when", created, last_update AS lastUpdate FROM login_attempt';

/**
Expand Down Expand Up @@ -76,7 +72,7 @@ public function fetchAll(): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, LoginAttempt::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -97,7 +93,7 @@ public function fetchLimit(int $offset, int $rowCount): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, LoginAttempt::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -114,7 +110,7 @@ public function fetchAttemptsWithSameUser(string $userName, int $timeInSeconds):

$pdos->bindParam(':user_name', $userName, PDO::PARAM_STR);

$time = (int) \date('YmdHis', \time() - $timeInSeconds);
$time = (int) date('YmdHis', time() - $timeInSeconds);
$pdos->bindParam(':time', $time, PDO::PARAM_INT);

$pdos->execute();
Expand All @@ -136,7 +132,7 @@ public function fetchAttemptsWithSameSession(string $sessionId, int $timeInSecon

$pdos->bindParam(':session_id', $sessionId, PDO::PARAM_STR);

$time = (int) \date('YmdHis', \time() - $timeInSeconds);
$time = (int) date('YmdHis', time() - $timeInSeconds);
$pdos->bindParam(':time', $time, PDO::PARAM_INT);

$pdos->execute();
Expand All @@ -158,7 +154,7 @@ public function fetchAttemptsWithSameIp(string $ipAddress, int $timeInSeconds):

$pdos->bindParam(':ip', $ipAddress, PDO::PARAM_STR);

$time = (int) \date('YmdHis', \time() - $timeInSeconds);
$time = (int) date('YmdHis', time() - $timeInSeconds);
$pdos->bindParam(':time', $time, PDO::PARAM_INT);

$pdos->execute();
Expand All @@ -177,7 +173,7 @@ public function deleteOldLoginAttempts(int $timeInSeconds): bool
{
$pdos = $this->pdo->prepare('DELETE FROM login_attempt WHERE date_time < :time');

$time = (int) \date('YmdHis', \time() - $timeInSeconds);
$time = (int) date('YmdHis', time() - $timeInSeconds);
$pdos->bindParam(':time', $time, PDO::PARAM_INT);

$pdos->execute();
Expand All @@ -201,6 +197,7 @@ protected function concreteCreate(): DomainObjectInterface
* storage record.
*
* @param DomainObjectInterface $loginAttempt
*
* @return void
*/
protected function concreteInsert(DomainObjectInterface &$loginAttempt): void
Expand All @@ -227,6 +224,7 @@ protected function concreteInsert(DomainObjectInterface &$loginAttempt): void
* Update a LoginAttempt object in persistent storage.
*
* @param DomainObjectInterface $loginAttempt
*
* @return void
*/
protected function concreteUpdate(DomainObjectInterface $loginAttempt): void
Expand Down Expand Up @@ -257,6 +255,7 @@ protected function concreteUpdate(DomainObjectInterface $loginAttempt): void
* deletion.
*
* @param DomainObjectInterface $domainObject
*
* @return void
*/
protected function concreteDelete(DomainObjectInterface &$loginAttempt): void
Expand All @@ -280,7 +279,9 @@ protected function concreteDelete(DomainObjectInterface &$loginAttempt): void
* Check for valid domain Object.
*
* @param DomainObjectInterface $domainObject
*
* @return void
*
* @throws InvalidArgumentException if the domain object isn't of the type required by mapper
*/
protected function checkDomainObjectType(DomainObjectInterface $domainObject): void
Expand Down
23 changes: 11 additions & 12 deletions src/Linna/Authentication/UserMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@
*/
class UserMapper extends MapperAbstract implements UserMapperInterface
{
/**
* @var Password Password util for user object
*/
/** @var Password Password util for user object */
protected Password $password;

/**
* @var ExtendedPDO Database Connection
*/
/** @var ExtendedPDO Database Connection */
protected ExtendedPDO $pdo;

/**
* @var string Constant part of SELECT query
*/
/** @var string Constant part of SELECT query */
protected string $baseQuery = 'SELECT user_id AS id, uuid, name, email, description, password, active, created, last_update AS lastUpdate FROM user';

/**
Expand Down Expand Up @@ -82,7 +76,7 @@ public function fetchByName(string $userName): DomainObjectInterface
{
$pdos = $this->pdo->prepare("{$this->baseQuery} WHERE md5(name) = :name");

$hashedUserName = \md5($userName);
$hashedUserName = md5($userName);

$pdos->bindParam(':name', $hashedUserName, PDO::PARAM_STR);
$pdos->execute();
Expand All @@ -105,7 +99,7 @@ public function fetchAll(): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, User::class, [$this->password]);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -126,7 +120,7 @@ public function fetchLimit(int $offset, int $rowCount): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, User::class, [$this->password]);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -145,6 +139,7 @@ protected function concreteCreate(): DomainObjectInterface
* storage record.
*
* @param DomainObjectInterface $user
*
* @return void
*/
protected function concreteInsert(DomainObjectInterface &$user): void
Expand All @@ -171,6 +166,7 @@ protected function concreteInsert(DomainObjectInterface &$user): void
* Update a User object in persistent storage.
*
* @param DomainObjectInterface $user
*
* @return void
*/
protected function concreteUpdate(DomainObjectInterface $user): void
Expand Down Expand Up @@ -201,6 +197,7 @@ protected function concreteUpdate(DomainObjectInterface $user): void
* deletion.
*
* @param DomainObjectInterface $domainObject
*
* @return void
*/
protected function concreteDelete(DomainObjectInterface &$user): void
Expand All @@ -224,7 +221,9 @@ protected function concreteDelete(DomainObjectInterface &$user): void
* Check for valid domain Object.
*
* @param DomainObjectInterface $domainObject
*
* @return void
*
* @throws InvalidArgumentException if the domain object isn't of the type required by mapper
*/
protected function checkDomainObjectType(DomainObjectInterface $domainObject): void
Expand Down
8 changes: 2 additions & 6 deletions src/Linna/Authorization/EnhancedUserMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@
*/
class EnhancedUserMapper extends UserMapper implements EnhancedUserMapperInterface
{
/**
* @var PermissionMapperInterface Permission Mapper
*/
/** @var PermissionMapperInterface Permission Mapper */
protected PermissionMapperInterface $permissionMapper;

/**
* @var RoleToUserMapperInterface Role to user Mapper
*/
/** @var RoleToUserMapperInterface Role to user Mapper */
protected RoleToUserMapperInterface $roleToUserMapper;

/**
Expand Down
22 changes: 9 additions & 13 deletions src/Linna/Authorization/PermissionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@
*/
class PermissionMapper extends MapperAbstract implements PermissionMapperInterface
{
/**
* @var ExtendedPDO Database Connection
*/
/** @var ExtendedPDO Database Connection */
protected ExtendedPDO $pdo;

/**
* @var string Constant part of SELECT query
*/
/** @var string Constant part of SELECT query */
protected string $baseQuery = 'SELECT permission_id AS id, name, description, created, last_update AS lastUpdate FROM permission';

/**
Expand Down Expand Up @@ -85,7 +81,7 @@ public function fetchAll(): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -101,7 +97,7 @@ public function fetchLimit(int $offset, int $rowCount): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand Down Expand Up @@ -129,7 +125,7 @@ public function fetchByRoleId(int $roleId): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -151,7 +147,7 @@ public function fetchByRoleName(string $roleName): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand Down Expand Up @@ -191,7 +187,7 @@ public function fetchByUserId(int $userId): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand Down Expand Up @@ -225,7 +221,7 @@ public function fetchByUserName(string $userName): array

$array = $pdos->fetchAll(PDO::FETCH_CLASS, Permission::class);

return \array_combine(\array_column($array, 'id'), $array);
return array_combine(array_column($array, 'id'), $array);
}

/**
Expand All @@ -252,7 +248,7 @@ public function fetchUserPermissionHashTable(int $userId): array
$pdos->bindParam(':id', $userId, PDO::PARAM_INT);
$pdos->execute();

return \array_flip($pdos->fetchAll(PDO::FETCH_COLUMN));
return array_flip($pdos->fetchAll(PDO::FETCH_COLUMN));
}

/**
Expand Down
Loading

0 comments on commit db8ffc0

Please sign in to comment.