Passed
Pull Request — develop (#785)
by Alejandro
15:27
created

CocurSymfonySluggerBridge::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Core\Util;
6
7
use Cocur\Slugify\SlugifyInterface;
8
use Symfony\Component\String\AbstractUnicodeString;
9
use Symfony\Component\String\Slugger\SluggerInterface;
10
11
use function Symfony\Component\String\s;
12
13
class CocurSymfonySluggerBridge implements SluggerInterface
14
{
15
    private SlugifyInterface $slugger;
16
17
    public function __construct(SlugifyInterface $slugger)
18
    {
19
        $this->slugger = $slugger;
20
    }
21
22
    public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
23
    {
24
        return s($this->slugger->slugify($string, $separator));
0 ignored issues
show
Bug Best Practice introduced by
The expression return s($this->slugger-...y($string, $separator)) could return the type Symfony\Component\String\ByteString which is incompatible with the type-hinted return Symfony\Component\String\AbstractUnicodeString. Consider adding an additional type-check to rule them out.
Loading history...
25
    }
26
}
27