private function getWidth(string $imagePath) : int
{
$fragments = explode('-', $imagePath);
if (count($fragments) < 2) {
header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 500 ' . 'Server Error ImgErr00');
die("Nope! Image fragments missing.");
}
$width = (int) explode('.', $fragments[1])[0];
if (!in_array($width, $this->allowedWidths)) {
header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 500 ' . 'Server Error ImgErr01');
die("Nope! Disallowed width: " . $width . " for image " . $imagePath);
}
return $width;
}