Completed
Push — master ( d55578...b36807 )
by Arman
16s queued 12s
created

CryptorException   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 79
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A publicKeyNotProvided() 0 3 1
A configNotFound() 0 3 1
A invalidCipher() 0 3 1
A privateKeyNotProvided() 0 3 1
A noPublicKeyCreated() 0 3 1
A noPrivateKeyCreated() 0 3 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.5.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class CryptorException
19
 * @package Quantum\Exceptions
20
 */
21
class CryptorException extends \Exception
22
{
23
24
    /**
25
     * Open SSL Public key not created yet
26
     */
27
    const OPENSSL_PUBLIC_KEY_NOT_CREATED = 'Public key not created yet';
28
29
    /**
30
     * Open SSL Private key not created yet
31
     */
32
    const OPENSSL_PRIVATE_KEY_NOT_CREATED = 'Private key not created yet';
33
34
    /**
35
     * Open SSL Public key is not provided
36
     */
37
    const OPENSSL_PUBLIC_KEY_NOT_PROVIDED = 'Public key is not provided';
38
39
    /**
40
     * Open SSL Private key is not provided
41
     */
42
    const OPENSSL_PRIVATE_KEY_NOT_PROVIDED = 'Private key is not provided';
43
44
    /**
45
     * Open SSL chiper is invalid
46
     */
47
    const OPENSSEL_INVALID_CIPHER = 'The cipher is invalid';
48
49
    /**
50
     * Open SSL config not found
51
     */
52
    const OPENSSEL_CONFIG_NOT_FOUND = 'Could not load openssl.cnf properly.';
53
54
    /**
55
     * @return \Quantum\Exceptions\CryptorException
56
     */
57
    public static function configNotFound(): CryptorException
58
    {
59
        return new static(self::OPENSSEL_CONFIG_NOT_FOUND, E_WARNING);
60
    }
61
62
    /**
63
     * @return \Quantum\Exceptions\CryptorException
64
     */
65
    public static function noPublicKeyCreated(): CryptorException
66
    {
67
        return new static(self::OPENSSL_PUBLIC_KEY_NOT_CREATED, E_WARNING);
68
    }
69
70
    /**
71
     * @return \Quantum\Exceptions\CryptorException
72
     */
73
    public static function noPrivateKeyCreated(): CryptorException
74
    {
75
        return new static(self::OPENSSL_PRIVATE_KEY_NOT_CREATED, E_WARNING);
76
    }
77
78
    /**
79
     * @return \Quantum\Exceptions\CryptorException
80
     */
81
    public static function publicKeyNotProvided(): CryptorException
82
    {
83
        return new static(self::OPENSSL_PUBLIC_KEY_NOT_PROVIDED, E_WARNING);
84
    }
85
86
    /**
87
     * @return \Quantum\Exceptions\CryptorException
88
     */
89
    public static function privateKeyNotProvided(): CryptorException
90
    {
91
        return new static(self::OPENSSL_PRIVATE_KEY_NOT_PROVIDED, E_WARNING);
92
    }
93
94
    /**
95
     * @return \Quantum\Exceptions\CryptorException
96
     */
97
    public static function invalidCipher(): CryptorException
98
    {
99
        return new static(self::OPENSSEL_INVALID_CIPHER, E_WARNING);
100
    }
101
}
102