Passed
Push — master ( c1e4c2...ec18f7 )
by Alexander
02:08 queued 10s
created

UserException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 4
c 1
b 0
f 1
dl 0
loc 18
ccs 3
cts 3
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Vasoft\VersionIncrement\Exceptions;
6
7
/**
8
 * Class UserException.
9
 *
10
 * Base class for user-defined exceptions in the application. Ensures that user-defined error codes start from 5000.
11
 * Developers can use this class directly or extend it to create custom exceptions.
12
 */
13
class UserException extends ApplicationException
14
{
15
    /**
16
     * The base offset for user-defined error codes.
17
     */
18
    private const BASE_CODE_OFFSET = 5000;
19
20
    /**
21
     * Constructor for UserException.
22
     *
23
     * @param int             $code     the user-defined error code (will be offset by 5000)
24
     * @param string          $message  the error message
25
     * @param null|\Throwable $previous the previous exception, if any
26
     */
27 1
    public function __construct(int $code, string $message, ?\Throwable $previous = null)
28
    {
29 1
        $this->applicationCode = self::BASE_CODE_OFFSET + $code;
30 1
        parent::__construct($message, $previous);
31
    }
32
}
33