Passed
Push — master ( 266d2c...9f91a2 )
by Caen
11:14 queued 08:29
created

ImplementsStringHelpers   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeTitle() 0 8 1
1
<?php
2
3
namespace Hyde\Framework\Foundation\Concerns;
4
5
use Illuminate\Support\Str;
6
7
/**
8
 * @internal Single-use trait for the HydeKernel class.
9
 *
10
 * @see \Hyde\Framework\HydeKernel
11
 */
12
trait ImplementsStringHelpers
13
{
14
    public function makeTitle(string $slug): string
15
    {
16
        $alwaysLowercase = ['a', 'an', 'the', 'in', 'on', 'by', 'with', 'of', 'and', 'or', 'but'];
17
18
        return ucfirst(str_ireplace(
0 ignored issues
show
Bug introduced by
It seems like str_ireplace($alwaysLowe...t\Str::headline($slug)) can also be of type array; however, parameter $string of ucfirst() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        return ucfirst(/** @scrutinizer ignore-type */ str_ireplace(
Loading history...
19
            $alwaysLowercase,
20
            $alwaysLowercase,
21
            Str::headline($slug)
22
        ));
23
    }
24
}
25