Exception   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getDialogue() 0 4 1
1
<?php
2
/**
3
 * Sendmail package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2010, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT MIT
8
 */
9
10
namespace Sendmail\Sender\Smtp;
11
12
/**
13
 * Dialogue exception.
14
 *
15
 * @author  Peter Gribanov <[email protected]>
16
 */
17
class Exception extends \Exception
18
{
19
    /**
20
     * @var Dialogue
21
     */
22
    protected $dialogue;
23
24
    /**
25
     * @param Dialogue $dialogue
26
     */
27 5
    public function __construct(Dialogue $dialogue)
28
    {
29 5
        $this->dialogue = $dialogue;
30
31 5
        $response = explode("\n", $dialogue->getLog());
32 5
        $response = array_shift($response);
33 5
        if (preg_match('/^(\d{3})(.+)/', $response, $match)) {
34 3
            parent::__construct(trim($match[2]), (int) $match[1]);
35
        } else {
36 2
            parent::__construct(trim($response), 500);
37
        }
38 5
    }
39
40
    /**
41
     * @return Dialogue
42
     */
43 1
    public function getDialogue()
44
    {
45 1
        return $this->dialogue;
46
    }
47
}
48