public static function castInt($value): int
    {
        if ($value !== null && !is_scalar($value)) {
            throw new InvalidArgumentException('Value could not be parsed to integer');
        }

        return (int)$value;
    }