type = self::INFO; $f = abj_service('functions'); $typeStr = is_string($type) ? $type : (is_scalar($type) ? (string)$type : ''); $VALID_TYPES = array(self::ERROR, self::WARNING, self::SUCCESS, self::INFO); if (!in_array($typeStr, $VALID_TYPES)) { if ($f->strtolower($typeStr) == 'info') { $typeStr = self::INFO; } else if ($f->strtolower($typeStr) == 'warning') { $typeStr = self::WARNING; } else if ($f->strtolower($typeStr) == 'success') { $typeStr = self::SUCCESS; } else if ($f->strtolower($typeStr) == 'error') { $typeStr = self::ERROR; } else { throw new Exception("Invalid type passed to constructor (" . esc_html($typeStr) . "). Expected: " . (string)json_encode($VALID_TYPES)); } } $this->type = $typeStr; $this->message = $message; } /** @return string */ function getType(): string { return $this->type; } /** @return mixed */ function getMessage() { return $this->message; } }