Skip to content

Commit c89de14

Browse files
stfndamjanovicgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 80456c7 commit c89de14

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

src/HashConfig.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
class HashConfig
88
{
9-
const CHARSET_UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
10-
const CHARSET_LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
11-
const CHARSET_NUMERIC = "0123456789";
9+
const CHARSET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
10+
11+
const CHARSET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
12+
13+
const CHARSET_NUMERIC = '0123456789';
1214

1315
protected $length;
1416

@@ -27,7 +29,7 @@ class HashConfig
2729
public function __construct($length = 16)
2830
{
2931
$this->length = $length;
30-
$this->charset = self::CHARSET_LOWERCASE . self::CHARSET_UPPERCASE . self::CHARSET_NUMERIC;
32+
$this->charset = self::CHARSET_LOWERCASE.self::CHARSET_UPPERCASE.self::CHARSET_NUMERIC;
3133
}
3234

3335
public static function make($length = 16)
@@ -52,7 +54,7 @@ public static function fromArray(array $array)
5254

5355
public function validate()
5456
{
55-
if (!is_string($this->charset) || empty($this->charset)) {
57+
if (! is_string($this->charset) || empty($this->charset)) {
5658
throw InvalidConfigException::invalidCharset();
5759
}
5860

src/InvalidConfigException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public static function invalidCharset()
1818

1919
public static function propertyNotPositiveNumber($property)
2020
{
21-
return new self(ucfirst($property) . " must be positive number.");
21+
return new self(ucfirst($property).' must be positive number.');
2222
}
2323
}

src/RandomHash.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ public function generate()
4949
$hash .= $charset[rand(0, strlen($charset) - 1)];
5050
}
5151

52-
$hash = $this->config->getPrefix() . $hash . $this->config->getSuffix();
52+
$hash = $this->config->getPrefix().$hash.$this->config->getSuffix();
5353

5454
if ($this->shouldSkip($hash)) {
5555
$i--;
5656
$this->skipHash($hash);
57+
5758
continue;
5859
}
5960

@@ -109,7 +110,7 @@ protected function reset()
109110

110111
protected function skipHash($hash)
111112
{
112-
if (!in_array($hash, $this->skipped)) {
113+
if (! in_array($hash, $this->skipped)) {
113114
$this->skipped[] = $hash;
114115
}
115116
}

tests/RandomHashTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Stfn\RandomHash\Tests;
44

55
use PHPUnit\Framework\TestCase;
6+
use Stfn\RandomHash\HashConfig;
67
use Stfn\RandomHash\InvalidConfigException;
78
use Stfn\RandomHash\RandomHash;
8-
use Stfn\RandomHash\HashConfig;
99

1010
class RandomHashTest extends TestCase
1111
{
@@ -28,33 +28,33 @@ public function test_if_it_can_generate_hash_with_specific_length()
2828
public function test_if_it_can_generate_hash_with_specific_prefix()
2929
{
3030
$config = new HashConfig();
31-
$config->prefix("PREFIX");
31+
$config->prefix('PREFIX');
3232

3333
$instance = new RandomHash($config);
3434
$hash = $instance->generate();
3535

36-
$this->assertStringStartsWith("PREFIX", $hash);
36+
$this->assertStringStartsWith('PREFIX', $hash);
3737

38-
$config->prefix("NEW_PREFIX");
38+
$config->prefix('NEW_PREFIX');
3939
$hash = $instance->generate();
4040

41-
$this->assertStringStartsWith("NEW_PREFIX", $hash);
41+
$this->assertStringStartsWith('NEW_PREFIX', $hash);
4242
}
4343

4444
public function test_if_it_can_generate_hash_with_specific_suffix()
4545
{
4646
$config = new HashConfig();
47-
$config->suffix("SUFFIX");
47+
$config->suffix('SUFFIX');
4848

4949
$instance = new RandomHash($config);
5050
$hash = $instance->generate();
5151

52-
$this->assertStringEndsWith("SUFFIX", $hash);
52+
$this->assertStringEndsWith('SUFFIX', $hash);
5353

54-
$config->suffix("NEW_SUFFIX");
54+
$config->suffix('NEW_SUFFIX');
5555
$hash = $instance->generate();
5656

57-
$this->assertStringEndsWith("NEW_SUFFIX", $hash);
57+
$this->assertStringEndsWith('NEW_SUFFIX', $hash);
5858
}
5959

6060
public function test_if_it_can_generate_hash_with_specific_count()
@@ -123,7 +123,7 @@ public function test_if_it_can_generate_alphanumeric()
123123
{
124124
$config = new HashConfig();
125125
$config->length(10)
126-
->charset(HashConfig::CHARSET_UPPERCASE . HashConfig::CHARSET_LOWERCASE . HashConfig::CHARSET_NUMERIC);
126+
->charset(HashConfig::CHARSET_UPPERCASE.HashConfig::CHARSET_LOWERCASE.HashConfig::CHARSET_NUMERIC);
127127

128128
$instance = new RandomHash($config);
129129
$hash = $instance->generate();
@@ -173,7 +173,7 @@ public function test_if_it_can_generate_hashes_from_array_config()
173173
$hashes = RandomHash::fromConfig([
174174
'length' => 12,
175175
'prefix' => $prefix,
176-
'count' => 10
176+
'count' => 10,
177177
])->generate();
178178

179179
$this->assertStringStartsWith($prefix, $hashes[0]);

0 commit comments

Comments
 (0)