| Total Complexity | 7 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class URLService |
||
| 13 | { |
||
| 14 | private RouterInterface $router; |
||
| 15 | |||
| 16 | public function __construct(RouterInterface $router) |
||
| 17 | { |
||
| 18 | $this->router = $router; |
||
| 19 | } |
||
| 20 | |||
| 21 | // Check slugs. |
||
| 22 | public function isCanonical(Property $property, Request $request): bool |
||
| 32 | } |
||
| 33 | |||
| 34 | // Generate correct canonical URL. |
||
| 35 | public function generateCanonical(Property $property): string |
||
| 36 | { |
||
| 37 | return $this->router->generate('property_show', [ |
||
| 38 | 'id' => $property->getId(), |
||
| 39 | 'citySlug' => $property->getCity()->getSlug(), |
||
| 40 | 'slug' => $property->getSlug(), |
||
| 41 | ], UrlGeneratorInterface::ABSOLUTE_URL); |
||
| 42 | } |
||
| 43 | |||
| 44 | // Check referer host. |
||
| 45 | public function isRefererFromCurrentHost(Request $request): bool |
||
| 52 | } |
||
| 53 | } |
||
| 54 |