Passed
Push — master ( ec3c40...d6cbfc )
by Caen
13:02 queued 13s
created

ImplementsStringHelpers::markdown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Foundation\Concerns;
6
7
use Hyde\Markdown\Models\Markdown;
8
use Illuminate\Support\HtmlString;
9
use Illuminate\Support\Str;
10
11
/**
12
 * @internal Single-use trait for the HydeKernel class.
13
 *
14
 * @see \Hyde\Foundation\HydeKernel
15
 */
16
trait ImplementsStringHelpers
17
{
18
    public function makeTitle(string $slug): string
19
    {
20
        $alwaysLowercase = ['a', 'an', 'the', 'in', 'on', 'by', 'with', 'of', 'and', 'or', 'but'];
21
22
        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

22
        return ucfirst(/** @scrutinizer ignore-type */ str_ireplace(
Loading history...
23
            $alwaysLowercase,
24
            $alwaysLowercase,
25
            Str::headline($slug)
26
        ));
27
    }
28
29
    public function markdown(string $text): HtmlString
30
    {
31
        return new HtmlString(Markdown::render($text));
32
    }
33
}
34