-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorCode.php
45 lines (40 loc) · 1.22 KB
/
ErrorCode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
//Created by FO on 20/01/2021
namespace FO;
/**
* Class ErrorCode. Represents errors using integers and can retrieve the description of those errors from the ErrorCategories they belong to
*/
class ErrorCode
{
private int $value; //The numeric value of this ErrorCode
private \FO\ErrorCategory\IErrorCategory $category;
/**
* ErrorCode constructor.
* @param int $value
* @param \FO\ErrorCategory\IErrorCategory $category
*/
public function __construct(int $value, ErrorCategory\IErrorCategory $category)
{
//initialize the properties of this ErrorCode
$this->value = $value;
$this->category = $category;
}
/**
* @brief: Returns the numeric value of this ErrorCode
* @return int: The integral value of this ErrorCode
*/
public function value(): int
{
//return the value of the ErrorCode
return $this->value;
}
/**
* @brief: gets the message that maps to this ErrorCode's value, as defined by its Category($this->Category)
* @return string
*/
public function message(): string
{
//retrieve the message from the category
return $this->category->message($this->value);
}
}