<?php
/**
 * Matador Jobs / Core / Activity Severity Enumeration
 *
 * @link        https://matadorjobs.com/
 * @since       3.9.0
 *
 * @package     Matador Jobs Board
 * @subpackage  Core
 * @author      Matador Holdings, Inc
 * @copyright   (c) 2017-2024, Matador Holdings, Inc
 *
 * @license     http://opensource.org/licenses/gpl-3.0.php GNU Public License
 */

namespace matador\MatadorJobs\Core;

/**
 * Enum Logger Activity Severity Level
 *
 * @since 3.9.0
 */
enum Severity: string {

	/**
	 * NOTE
	 *
	 * @since 3.9.0
	 *
	 * For log entries that a purely informational, generally deep development centric, ie: explaining each minute step.
	 */
	case NOTE = 'note';

	/**
	 * NOTICE
	 *
	 * @since 3.9.0
	 *
	 * For log entries that are primarily informational but highlight usually user-initiated changes in behavior, ie:
	 * explaining a job being skipped due to a skip filter.
	 */
	case NOTICE = 'notice';

	/**
	 * WARNING
	 *
	 * @since 3.9.0
	 *
	 * For log entries that inform of a likely issue, but one we recover from, ie: job not synced due to missing title,
	 * sync fails due to improper credentials.
	 */
	case WARNING = 'warning';

	/**
	 * ERROR
	 *
	 * @since 3.9.0
	 *
	 * For log entries that inform of an error, usually that we can recover from, ie: sync failed due to 500 error at
	 * remote server.
	 */
	case ERROR = 'error';

	/**
	 * CRITICAL
	 *
	 * @since 3.9.0
	 *
	 * For log entries that shouldn't happen, ie: WP Errors, errors at points after data should reliable.
	 */
	case CRITICAL = 'critical';

	/**
	 * INFO
	 *
	 * @since 3.9.0
	 *
	 * Non error peace-of-mind information we always want logged.
	 */
	case INFO = 'info';

	/**
	 * Severity Level
	 *
	 * Returns an int value for the severity level of the enum.
	 *
	 * @since 3.9.0
	 *
	 * @return int
	 */
	public function level(): int {

		return match ( $this ) {
			Severity::NOTE     => 1,
			Severity::NOTICE   => 2,
			Severity::WARNING  => 3,
			Severity::ERROR    => 4,
			Severity::CRITICAL => 5,
			Severity::INFO     => 6,
		};
	}
}