1 | <?php |
||
17 | class UrlShortener implements UrlShortenerInterface |
||
18 | { |
||
19 | use TagManagerTrait; |
||
20 | |||
21 | const DEFAULT_CHARS = '123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'; |
||
22 | |||
23 | /** |
||
24 | * @var ClientInterface |
||
25 | */ |
||
26 | private $httpClient; |
||
27 | /** |
||
28 | * @var EntityManagerInterface |
||
29 | */ |
||
30 | private $em; |
||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $chars; |
||
35 | /** |
||
36 | * @var Cache |
||
37 | */ |
||
38 | private $cache; |
||
39 | |||
40 | /** |
||
41 | * UrlShortener constructor. |
||
42 | * @param ClientInterface $httpClient |
||
43 | * @param EntityManagerInterface $em |
||
44 | * @param Cache $cache |
||
45 | * @param string $chars |
||
46 | * |
||
47 | * @Inject({"httpClient", "em", Cache::class, "config.url_shortener.shortcode_chars"}) |
||
48 | */ |
||
49 | 7 | public function __construct( |
|
60 | |||
61 | /** |
||
62 | * Creates and persists a unique shortcode generated for provided url |
||
63 | * |
||
64 | * @param UriInterface $url |
||
65 | * @param string[] $tags |
||
66 | * @return string |
||
67 | * @throws InvalidUrlException |
||
68 | * @throws RuntimeException |
||
69 | */ |
||
70 | 4 | public function urlToShortCode(UriInterface $url, array $tags = []) |
|
110 | |||
111 | /** |
||
112 | * Tries to perform a GET request to provided url, returning true on success and false on failure |
||
113 | * |
||
114 | * @param UriInterface $url |
||
115 | * @return bool |
||
116 | */ |
||
117 | 3 | protected function checkUrlExists(UriInterface $url) |
|
125 | |||
126 | /** |
||
127 | * Generates the unique shortcode for an autoincrement ID |
||
128 | * |
||
129 | * @param int $id |
||
130 | * @return string |
||
131 | */ |
||
132 | 1 | protected function convertAutoincrementIdToShortCode($id) |
|
146 | |||
147 | /** |
||
148 | * Tries to find the mapped URL for provided short code. Returns null if not found |
||
149 | * |
||
150 | * @param string $shortCode |
||
151 | * @return string|null |
||
152 | * @throws InvalidShortCodeException |
||
153 | */ |
||
154 | 3 | public function shortCodeToUrl($shortCode) |
|
180 | } |
||
181 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: