ColorGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 7 2
A createDarkColor() 0 4 1
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