Skip to content

Commit 2db99cc

Browse files
committed
styleci psr2
1 parent 87bc2f5 commit 2db99cc

10 files changed

+41
-37
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ php:
77
- 'hhvm'
88
matrix:
99
allow_failures:
10-
- php: nightly
10+
- php: nightly
1111
install:
1212
- composer install
1313
script:
14-
- ./vendor/bin/phpunit --coverage-clover ./tests/Logs/clover.xml
15-
- ./vendor/bin/psalm
14+
- ./vendor/bin/phpunit --coverage-clover ./tests/Logs/clover.xml
15+
- ./vendor/bin/psalm
1616
after_script:
17-
- php vendor/bin/php-coveralls -v
17+
- php vendor/bin/php-coveralls -v

phpunit.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
</whitelist>
2424
</filter>
2525
<php>
26-
26+
2727
</php>
28-
</phpunit>
28+
</phpunit>

psalm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
totallyTyped="false"
44
>
55
<projectFiles>
6-
<directory name="src" />
6+
<directory name="src"/>
77
</projectFiles>
88
</psalm>

src/AbstractPasswordExposedChecker.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
namespace DivineOmega\PasswordExposed;
44

55
use Psr\Cache\CacheItemPoolInterface;
6-
use Psr\Cache\InvalidArgumentException;
76
use Psr\Http\Client\ClientExceptionInterface;
87
use Psr\Http\Client\ClientInterface;
98
use Psr\Http\Message\RequestFactoryInterface;
109
use Psr\Http\Message\ResponseInterface;
1110
use Psr\Http\Message\UriFactoryInterface;
1211

1312
/**
14-
* Class AbstractPasswordExposedChecker
13+
* Class AbstractPasswordExposedChecker.
1514
*/
1615
abstract class AbstractPasswordExposedChecker implements PasswordExposedCheckerInterface
1716
{
@@ -33,7 +32,7 @@ public function passwordExposed(string $password): string
3332
public function passwordExposedByHash(string $hash): string
3433
{
3534
$cache = $this->getCache();
36-
$cacheKey = substr($hash, 0, 2) . '_' . substr($hash, 2, 3);
35+
$cacheKey = substr($hash, 0, 2).'_'.substr($hash, 2, 3);
3736
$body = null;
3837

3938
try {
@@ -43,7 +42,7 @@ public function passwordExposedByHash(string $hash): string
4342
if ($cacheItem->isHit()) {
4443
$body = $cacheItem->get();
4544
}
46-
} catch (InvalidArgumentException $e) {
45+
} catch (\Exception $e) {
4746
$cacheItem = null;
4847
}
4948

@@ -108,12 +107,13 @@ public function isExposedByHash(string $hash): ?bool
108107
/**
109108
* @param $hash
110109
*
111-
* @return ResponseInterface
112110
* @throws \Psr\Http\Client\ClientExceptionInterface
111+
*
112+
* @return ResponseInterface
113113
*/
114114
protected function makeRequest(string $hash): ResponseInterface
115115
{
116-
$uri = $this->getUriFactory()->createUri('https://api.pwnedpasswords.com/range/' . substr($hash, 0, 5));
116+
$uri = $this->getUriFactory()->createUri('https://api.pwnedpasswords.com/range/'.substr($hash, 0, 5));
117117
$request = $this->getRequestFactory()->createRequest('GET', $uri);
118118

119119
return $this->getClient()->sendRequest($request);

src/PasswordExposedChecker.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
use Psr\Http\Message\UriFactoryInterface;
1515

1616
/**
17-
* Class PasswordExposedChecker
17+
* Class PasswordExposedChecker.
1818
*/
1919
class PasswordExposedChecker extends AbstractPasswordExposedChecker
2020
{
21-
2221
/** @var ClientInterface|null */
2322
protected $client;
2423

@@ -50,8 +49,7 @@ public function __construct(
5049
?int $cacheLifeTime = null,
5150
?RequestFactoryInterface $requestFactory = null,
5251
?UriFactoryInterface $uriFactory = null
53-
)
54-
{
52+
) {
5553
$this->client = $client;
5654
$this->cache = $cache;
5755
$this->cacheLifeTime = $cacheLifeTime;
@@ -60,7 +58,7 @@ public function __construct(
6058
}
6159

6260
/**
63-
* @return ClientInterface
61+
* {@inheritdoc}
6462
*/
6563
protected function getClient(): ClientInterface
6664
{
@@ -92,7 +90,7 @@ protected function createClient(): ClientInterface
9290
}
9391

9492
/**
95-
* @return CacheItemPoolInterface
93+
* {@inheritdoc}
9694
*/
9795
protected function getCache(): CacheItemPoolInterface
9896
{
@@ -151,7 +149,7 @@ protected function createRequestFactory(): RequestFactoryInterface
151149
}
152150

153151
/**
154-
* @return UriFactoryInterface
152+
* {@inheritdoc}
155153
*/
156154
protected function getUriFactory(): UriFactoryInterface
157155
{
@@ -210,7 +208,7 @@ protected function createBundle(): ?Bundle
210208
*/
211209
protected function getBundleFromCertainty(): Bundle
212210
{
213-
$ourCertaintyDataDir = __DIR__ . '/../bundles';
211+
$ourCertaintyDataDir = __DIR__.'/../bundles';
214212

215213
if (!is_writable($ourCertaintyDataDir)) {
216214

src/PasswordExposedCheckerInterface.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
namespace DivineOmega\PasswordExposed;
44

55
/**
6-
* Interface PasswordExposedCheckerInterface
6+
* Interface PasswordExposedCheckerInterface.
77
*/
88
interface PasswordExposedCheckerInterface
99
{
10-
1110
public const NOT_EXPOSED = 'not_exposed';
1211
public const EXPOSED = 'exposed';
1312
public const UNKNOWN = 'unknown';

src/PasswordStatus.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace DivineOmega\PasswordExposed;
44

55
/**
6-
* Class PasswordStatus
6+
* Class PasswordStatus.
77
*/
88
abstract class PasswordStatus
99
{

tests/Unit/BundleInjectionTest.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ public function testLocalBundleInjection()
1616
$bundle = new Bundle(end($pemFiles));
1717

1818
$cache = new CacheItemPool();
19-
$cache->changeConfig([
20-
'cacheDirectory' => __DIR__.'/../../cache/',
21-
'gzipCompression' => false,
22-
]);
19+
$cache->changeConfig(
20+
[
21+
'cacheDirectory' => __DIR__.'/../../cache/',
22+
'gzipCompression' => false,
23+
]
24+
);
2325

24-
$passwordExposedChecker = new PasswordExposedChecker(null, $cache, $bundle);
26+
$passwordExposedChecker = new PasswordExposedChecker(null, $cache);
27+
$passwordExposedChecker->setBundle($bundle);
2528

2629
$this->assertEquals(PasswordStatus::EXPOSED, $passwordExposedChecker->passwordExposed('hunter2'));
2730
}

tests/Unit/PasswordExposedByHashTest.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ class PasswordExposedByHashTest extends TestCase
1616
protected function setUp()
1717
{
1818
$cache = new CacheItemPool();
19-
$cache->changeConfig([
20-
'cacheDirectory' => __DIR__.'/../../cache/',
21-
'gzipCompression' => false,
22-
]);
19+
$cache->changeConfig(
20+
[
21+
'cacheDirectory' => __DIR__.'/../../cache/',
22+
'gzipCompression' => false,
23+
]
24+
);
2325
$this->checker = new PasswordExposedChecker(null, $cache);
2426
}
2527

tests/Unit/PasswordExposedTest.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ class PasswordExposedTest extends TestCase
1616
protected function setUp()
1717
{
1818
$cache = new CacheItemPool();
19-
$cache->changeConfig([
20-
'cacheDirectory' => __DIR__.'/../../cache/',
21-
'gzipCompression' => false,
22-
]);
19+
$cache->changeConfig(
20+
[
21+
'cacheDirectory' => __DIR__.'/../../cache/',
22+
'gzipCompression' => false,
23+
]
24+
);
2325
$this->checker = new PasswordExposedChecker(null, $cache);
2426
}
2527

0 commit comments

Comments
 (0)