ACC SHELL

Path : /srv/www/vhosts/petrikov/test/
File Upload :
Current File : /srv/www/vhosts/petrikov/test/Exceptions.php

<?php
	class Error {
		
		const RELEVATION_UNKNOWN = 0;
		const RELEVATION_INFO = 1;
		const RELEVATION_WARNING = 2;
		const RELEVATION_ERROR = 3;
		
		const ERROR_UNKNOWN = 0;
		const ERROR_ADD_BAD_NUM = 1;

		private $code;
		private $relevation;
		private $file;
		private $line;

		public function __construct( $code, $relevation , $file , $line ) {
			setCode( $code );
			setRelevation( $relevation );
			setFile( $file );
			setLine( $line );
		}

		public function setCode( $code ) {
			$this->code = $code;
		}

		public function getCode() {
			return $this->code;
		}

		public function setRelevation( $relevation ) {
			$this->relevation = $relevation;
		}

		public function getRelevation() {
			return $this->relevation;
		}

		public function setFile( $file ) {
			$this->file = $file;
		}

		public function getFile() {
			return $this->file;
		}

		public function setLine( $line ) {
			$this->line = $line;
		}

		public function getLine() {
			return $this->line;
		}

		public function log() {
			// zalogovani chyby
		}
	}

	class ErrorStack {
		private $errors;
		
		public function  __construct() {
			$this->clearStack();
		}

		public function logAll() {
			if ( count( $errors ) > 0 ) {
				for ( $i = 0; $i < count( $errors ); $i++ ) {
					$errors[$i].log();
		
				}
			}
		}

		public function addError(  $code, $relevation = Exception::RELEVATION_UNKNOWN, $file = __FILE__ , $line = __LINE__ ) {	
			$errors[] = new Exception( $code, $relevation, $file, $line );
		}

		public function getError( $num ) {
			if ( $num >= 0 && $num <= count( $exceptions ) ) {
				return $exceptions[ $num ];
			} else {
				$this->addException( Exception::ERROR_ADD_BAD_NUM );
			}
		}

		public function getErrors() {
			return $errors;
		}
		
		public function clearStack() {
			$errors = array();
		}

		public function numErrors() {
			return count( $errors );
		}

		public function isException() {
			$num = $this->numErrors();
			return ( $num > 0 ) ? TRUE : FALSE;
		}	
	}

	$Error = new Error( 0, 1, __FILE__, __LINE__ );
?>

ACC SHELL 2018