Skip to content

Commit a162e4d

Browse files
style(*): Clean some code
1 parent c873e2b commit a162e4d

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

src/ApiCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,10 @@ private function hit(string $ip): string
694694
}
695695

696696
/**
697+
* @param string $cacheScope
697698
* @param $value
698699
*
700+
* @return string
699701
* @throws InvalidArgumentException
700702
* @throws Exception
701703
*/

src/Bouncer.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ class Bouncer
3131
/** @var LoggerInterface */
3232
private $logger;
3333

34-
/** @var array */
35-
private $config = [];
36-
3734
/** @var ApiCache */
3835
private $apiCache;
3936

@@ -62,25 +59,25 @@ public function configure(array $config): void
6259
// Process input configuration.
6360
$configuration = new Configuration();
6461
$processor = new Processor();
65-
$this->config = $processor->processConfiguration($configuration, [$config]);
62+
$finalConfig = $processor->processConfiguration($configuration, [$config]);
6663
/** @var int */
6764
$index = array_search(
68-
$this->config['max_remediation_level'],
65+
$finalConfig['max_remediation_level'],
6966
Constants::ORDERED_REMEDIATIONS
7067
);
7168
$this->maxRemediationLevelIndex = $index;
7269

7370
// Configure Api Cache.
7471
$this->apiCache->configure(
75-
$this->config['stream_mode'],
76-
$this->config['api_url'],
77-
$this->config['api_timeout'],
78-
$this->config['api_user_agent'],
79-
$this->config['api_key'],
80-
$this->config['cache_expiration_for_clean_ip'],
81-
$this->config['cache_expiration_for_bad_ip'],
82-
$this->config['fallback_remediation'],
83-
$this->config['geolocation']
72+
$finalConfig['stream_mode'],
73+
$finalConfig['api_url'],
74+
$finalConfig['api_timeout'],
75+
$finalConfig['api_user_agent'],
76+
$finalConfig['api_key'],
77+
$finalConfig['cache_expiration_for_clean_ip'],
78+
$finalConfig['cache_expiration_for_bad_ip'],
79+
$finalConfig['fallback_remediation'],
80+
$finalConfig['geolocation']
8481
);
8582
}
8683

src/Constants.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
*/
1717
class Constants
1818
{
19-
/** @var string The URL of the CrowdSec Central API */
20-
public const CAPI_URL = 'https://api.crowdsec.net/v2/';
21-
2219
/** @var string The Default URL of the CrowdSec LAPI */
2320
public const DEFAULT_LAPI_URL = 'http://localhost:8080';
2421

src/StandaloneBounce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ private function getCacheAdapterInstance(bool $forceReload = false): AbstractAda
9292
} catch (InvalidArgumentException $e) {
9393
throw new BouncerException('Error when connecting to Redis.'.' Please fix the Redis DSN or select another cache technology.');
9494
}
95-
9695
break;
96+
9797
default:
98-
throw new BouncerException('Unknown selected cache technology.');
98+
throw new BouncerException("Unknown selected cache technology: $cacheSystem");
9999
}
100100

101101
return $this->cacheAdapter;

0 commit comments

Comments
 (0)