Skip to content

Commit

Permalink
Align with changes in dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
prwater committed Sep 21, 2024
1 parent fa0e25d commit 69c2809
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/.phpunit.result.cache
/bin/
/composer.lock
/custom.task.properties
/custom.type.properties
/test/coverage.xml
/test/report/
/vendor/
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
"psr/log": "^3.0.0",
"setbased/exception": "^2.3.0",
"setbased/helper-cast": "^3.0.0",
"setbased/php-stratum-middle": "^5.11.0",
"setbased/php-stratum-mysql": "^6.6.0",
"setbased/php-stratum-middle": "^5.0.0",
"setbased/php-stratum-mysql": "^7.0.0",
"symfony/console": "^6.2.5"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"phing/phing": "^3.0.0-RC4",
"phpunit/phpunit": "^9.6.3",
"phing/phing": "^3.0.0",
"phpunit/phpunit": "^10.5.35",
"setbased/error-handler": "^1.3.0"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ReferenceObfuscatorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function compare(array $a, array $b): int
/**
* @inheritdoc
*/
protected function configure()
protected function configure(): void
{
$this->setName('plaisio:reference-obfuscator-generator')
->setDescription('Generates the keys and masks for the Reference Obfuscator')
Expand Down Expand Up @@ -179,7 +179,7 @@ private function extractLines(string $source): array
// Step 1: Find doc comment with annotation.
if (is_array($token) && $token[0]==T_DOC_COMMENT)
{
if (strpos($token[1], '@plaisio.obfuscator.labels')!==false)
if (str_contains($token[1], '@plaisio.obfuscator.labels'))
{
$line1 = $token[2];
$step = 2;
Expand Down
1 change: 1 addition & 0 deletions src/DevelopmentObfuscator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DevelopmentObfuscator implements Obfuscator
private string $alias;

//--------------------------------------------------------------------------------------------------------------------

/**
* Object constructor.
*
Expand Down
12 changes: 9 additions & 3 deletions src/DevelopmentObfuscatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public static function create(string $alias): Obfuscator
*/
public static function decode(?string $code, string $alias): ?int
{
if ($code===null || $code==='') return null;
if ($code===null || $code==='')
{
return null;
}

if (substr($code, 0, strlen($alias))!=$alias)
if (!str_starts_with($code, $alias))
{
throw new LogicException(sprintf("Labels '%s' and '%s' don't match.", substr($code, 0, strlen($alias)), $alias));
}
Expand All @@ -51,7 +54,10 @@ public static function decode(?string $code, string $alias): ?int
*/
public static function encode(?int $id, string $alias): ?string
{
if ($id===null) return null;
if ($id===null)
{
return null;
}

return $alias.'_'.$id;
}
Expand Down
5 changes: 4 additions & 1 deletion src/IdentityObfuscatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public static function create(string $alias): Obfuscator
*/
public static function decode(?string $code, string $alias): ?int
{
if ($code===null || $code==='') return null;
if ($code===null || $code==='')
{
return null;
}

if (preg_match('/^\d+$/', $code)!=1)
{
Expand Down
10 changes: 8 additions & 2 deletions src/ReferenceObfuscator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public function __construct(int $length, int $key, int $bitMask)
*/
public static function decrypt(?string $code, int $length, int $key, int $mask): ?int
{
if ($code===null || $code==='') return null;
if ($code===null || $code==='')
{
return null;
}

try
{
Expand Down Expand Up @@ -111,7 +114,10 @@ public static function decrypt(?string $code, int $length, int $key, int $mask):
*/
public static function encrypt(?int $id, int $length, int $key, int $mask): ?string
{
if ($id===null) return null;
if ($id===null)
{
return null;
}

$val = $id ^ $mask;
$result = 0;
Expand Down
1 change: 1 addition & 0 deletions src/ReferenceObfuscatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ReferenceObfuscatorFactory implements ObfuscatorFactory
public static array $labels = [];

//--------------------------------------------------------------------------------------------------------------------

/**
* @inheritdoc
*
Expand Down

0 comments on commit 69c2809

Please sign in to comment.