1 | <?php |
||
16 | class UrlShortener implements UrlShortenerInterface |
||
17 | { |
||
18 | const DEFAULT_CHARS = '123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'; |
||
19 | |||
20 | /** |
||
21 | * @var ClientInterface |
||
22 | */ |
||
23 | private $httpClient; |
||
24 | /** |
||
25 | * @var EntityManagerInterface |
||
26 | */ |
||
27 | private $em; |
||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $chars; |
||
32 | /** |
||
33 | * @var Cache |
||
34 | */ |
||
35 | private $cache; |
||
36 | |||
37 | /** |
||
38 | * UrlShortener constructor. |
||
39 | * @param ClientInterface $httpClient |
||
40 | * @param EntityManagerInterface $em |
||
41 | * @param Cache $cache |
||
42 | * @param string $chars |
||
43 | * |
||
44 | * @Inject({"httpClient", "em", Cache::class, "config.url_shortener.shortcode_chars"}) |
||
45 | */ |
||
46 | 7 | public function __construct( |
|
57 | |||
58 | /** |
||
59 | * Creates and persists a unique shortcode generated for provided url |
||
60 | * |
||
61 | * @param UriInterface $url |
||
62 | * @return string |
||
63 | * @throws InvalidUrlException |
||
64 | * @throws RuntimeException |
||
65 | */ |
||
66 | 4 | public function urlToShortCode(UriInterface $url) |
|
105 | |||
106 | /** |
||
107 | * Tries to perform a GET request to provided url, returning true on success and false on failure |
||
108 | * |
||
109 | * @param UriInterface $url |
||
110 | * @return bool |
||
111 | */ |
||
112 | 3 | protected function checkUrlExists(UriInterface $url) |
|
120 | |||
121 | /** |
||
122 | * Generates the unique shortcode for an autoincrement ID |
||
123 | * |
||
124 | * @param int $id |
||
125 | * @return string |
||
126 | */ |
||
127 | 1 | protected function convertAutoincrementIdToShortCode($id) |
|
141 | |||
142 | /** |
||
143 | * Tries to find the mapped URL for provided short code. Returns null if not found |
||
144 | * |
||
145 | * @param string $shortCode |
||
146 | * @return string|null |
||
147 | * @throws InvalidShortCodeException |
||
148 | */ |
||
149 | 3 | public function shortCodeToUrl($shortCode) |
|
175 | } |
||
176 |
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: