ColorGenerator::createDarkColor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Services;
12
13
/**
14
 * Class ColorGenerator.
15
 */
16
class ColorGenerator
17
{
18
    /**
19
     * @param  bool   $withPrefix
20
     * @return string
21
     */
22
    public function make(bool $withPrefix = true): string
23
    {
24
        return ($withPrefix ? '#' : '') .
25
            strtolower(sprintf('%02X', $this->createDarkColor())) .
26
            strtolower(sprintf('%02X', $this->createDarkColor())) .
27
            strtolower(sprintf('%02X', $this->createDarkColor()));
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    private function createDarkColor(): int
34
    {
35
        return random_int(100, 170);
36
    }
37
}
38