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

CocurSymfonySluggerBridge   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A slug() 0 3 1
A __construct() 0 3 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