BaseWrapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * User: jg
4
 * Date: 28/05/17
5
 * Time: 12:31
6
 */
7
8
namespace ByJG\Mail\Wrapper;
9
10
use ByJG\Mail\Envelope;
11
use ByJG\Mail\Exception\InvalidEMailException;
12
use ByJG\Util\Uri;
13
14
abstract class BaseWrapper implements MailWrapperInterface
15
{
16
    /**
17
     * @var \ByJG\Util\Uri
18
     */
19
    protected $uri = null;
20
21 15
    public function __construct(Uri $uri)
22
    {
23 15
        $this->uri = $uri;
24
    }
25
26
    /**
27
     * @param \ByJG\Mail\Envelope $envelope
28
     * @throws InvalidEMailException
29
     */
30 12
    public function validate(Envelope $envelope)
31
    {
32 12
        if (0 === count($envelope->getTo())) {
33
            throw new InvalidEMailException("Destination Email was not provided");
34
        }
35
36 12
        if ($envelope->getFrom() == "") {
37
            throw new InvalidEMailException("From email was not provided");
38
        }
39
    }
40
}
41