Skip to content

Commit 91dc3a8

Browse files
committed
Apply fixes from StyleCI
1 parent b63a4e0 commit 91dc3a8

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/InitialAvatar.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,25 @@ public function background($background)
207207

208208
return $this;
209209
}
210-
210+
211211
/**
212212
* Set background color to be randomly generated for each avatar.
213-
*
213+
*
214214
* @param bool $random
215-
* @param int $saturation Saturation value (0-100)
216-
* @param int $luminance Luminance value (0-100)
217-
*
215+
* @param int $saturation Saturation value (0-100)
216+
* @param int $luminance Luminance value (0-100)
217+
*
218218
* @return $this
219219
*/
220220
public function randomBackground($random = true, int $saturation = 85, int $luminance = 60)
221221
{
222222
$this->randomBgColor = (bool) $random;
223-
223+
224224
if ($random) {
225225
// Generate an initial random color
226226
$this->generateRandomColor($saturation, $luminance);
227227
}
228-
228+
229229
return $this;
230230
}
231231

@@ -470,10 +470,10 @@ public function getBackgroundColor()
470470
// Generate a new random color each time this method is called
471471
$this->generateRandomColor();
472472
}
473-
473+
474474
return $this->bgColor;
475475
}
476-
476+
477477
/**
478478
* Will return whether random background color is enabled.
479479
*
@@ -960,13 +960,13 @@ protected function getContrastColor($hexColor)
960960
return '#FFFFFF';
961961
}
962962
}
963-
963+
964964
/**
965965
* Generate a random background color.
966-
*
966+
*
967967
* @param int $saturation Saturation value (0-100)
968-
* @param int $luminance Luminance value (0-100)
969-
*
968+
* @param int $luminance Luminance value (0-100)
969+
*
970970
* @return string The generated hex color
971971
*/
972972
protected function generateRandomColor(int $saturation = 85, int $luminance = 60)
@@ -975,11 +975,11 @@ protected function generateRandomColor(int $saturation = 85, int $luminance = 60
975975
$hue = mt_rand(0, 359) / 360;
976976
$saturation /= 100;
977977
$luminance /= 100;
978-
978+
979979
$hexColor = $this->convertHSLtoRGB($hue, $saturation, $luminance);
980980
$this->bgColor = $hexColor;
981981
$this->fontColor = $this->getContrastColor($hexColor);
982-
982+
983983
return $hexColor;
984984
}
985985
}

tests/RandomBackgroundTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,60 @@ public function it_generates_random_background_colors()
1010
{
1111
$avatar = new InitialAvatar();
1212
$avatar->randomBackground(true);
13-
13+
1414
// Verify random background is enabled
1515
$this->assertTrue($avatar->getRandomBackgroundColor());
16-
16+
1717
// Get first color
1818
$firstColor = $avatar->getBackgroundColor();
19-
19+
2020
// Get second color - should be different
2121
$secondColor = $avatar->getBackgroundColor();
22-
22+
2323
// Colors should be different due to random generation
2424
$this->assertNotEquals($firstColor, $secondColor);
25-
25+
2626
// Disable random background
2727
$avatar->randomBackground(false);
2828
$this->assertFalse($avatar->getRandomBackgroundColor());
29-
29+
3030
// Set fixed background
3131
$fixedColor = '#123456';
3232
$avatar->background($fixedColor);
33-
33+
3434
// Get color multiple times - should be the same
3535
$this->assertEquals($fixedColor, $avatar->getBackgroundColor());
3636
$this->assertEquals($fixedColor, $avatar->getBackgroundColor());
3737
}
38-
38+
3939
/** @test */
4040
public function it_generates_different_avatars_with_random_background()
4141
{
4242
$avatar = new InitialAvatar();
4343
$avatar->randomBackground(true);
44-
44+
4545
// Generate two avatars
4646
$firstAvatar = $avatar->generate('Test User');
4747
$firstBgColor = $avatar->getBackgroundColor();
48-
48+
4949
$secondAvatar = $avatar->generate('Test User');
5050
$secondBgColor = $avatar->getBackgroundColor();
51-
51+
5252
// Background colors should be different
5353
$this->assertNotEquals($firstBgColor, $secondBgColor);
54-
54+
5555
// SVG test
5656
$avatar = new InitialAvatar();
5757
$avatar->randomBackground(true);
58-
58+
5959
// Generate two SVG avatars
6060
$firstSvg = $avatar->generateSvg('Test User');
6161
$firstSvgBgColor = $avatar->getBackgroundColor();
62-
62+
6363
$secondSvg = $avatar->generateSvg('Test User');
6464
$secondSvgBgColor = $avatar->getBackgroundColor();
65-
65+
6666
// Background colors should be different
6767
$this->assertNotEquals($firstSvgBgColor, $secondSvgBgColor);
6868
}
69-
}
69+
}

0 commit comments

Comments
 (0)