/** * Remove the given file extension from the url data array. * Modifies $data. * * @param array $data The url data * @param string $extension The file extension to remove * @throws UnexpectedValueException if the url doesn't end with the given extension */ protected function removeFileExtensionFromURLData(array &$data, $extension) { $length = count($data); if (!Util::stringEndsWith($data[$length - 1], $extension)) { throw new UnexpectedValueException("url doesn't end with {$extension}"); } $data[$length - 1] = substr($data[$length - 1], 0, strlen($data[$length - 1]) - strlen($extension)); }