ServiceError   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 3 1
A __construct() 0 4 1
A getCode() 0 3 1
1
<?php
2
/**
3
 * @author    Nurlan Mukhanov <[email protected]>
4
 * @copyright 2022 Nurlan Mukhanov
5
 * @license   https://en.wikipedia.org/wiki/MIT_License MIT License
6
 * @link      https://github.com/Falseclock/service-layer
7
 */
8
9
declare(strict_types=1);
10
11
namespace Falseclock\Service;
12
13
class ServiceError
14
{
15
    public const ERROR_INVALID_REQUEST = 1000000;
16
    public const ERROR_UNEXPECTED = 1000001;
17
    /** @var int */
18
    protected $code;
19
    /** @var string */
20
    protected $message;
21
22
    public function __construct(string $message, int $code = 0)
23
    {
24
        $this->message = $message;
25
        $this->code = $code;
26
    }
27
28
    /**
29
     * @return int
30
     */
31
    public function getCode(): int
32
    {
33
        return $this->code;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getMessage(): string
40
    {
41
        return $this->message;
42
    }
43
}
44