You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
917 B

<?php
namespace App\TwigExtensions;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class StringManipulationExtension extends AbstractExtension
{
public function getFunctions()
{
return [
new TwigFunction('turn_mot_code_to_url', [$this, 'TurnMOTCodeToURL']),
];
}
public function TurnMOTCodeToURL(string $motCode) : string
{
$groups = [
7=>"7-other-equipment"
];
$motCodeElements = explode(separator: '.', string: $motCode);
$builder = "https://www.gov.uk/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles/";
$builder .= $groups[intval(value: $motCodeElements[0])];
$builder .= "#section-";
$builder .= "-";
$builder .= $motCodeElements[1];
$builder .= "-";
$builder .= $motCodeElements[2];
return $builder;
}
}