MailTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMailDir() 0 4 1
A setUpMailDir() 0 5 2
A tearDownMailDir() 0 5 2
A cleanMail() 0 7 2
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDev/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2017 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDev\Test\Selenium;
11
12
use WebinoDev\Test\MailTrait as BaseMailTrait;
13
14
/**
15
 * WebDriver test mail trait
16
 *
17
 * Use this trait when you want a WebDriver mail testing.
18
 */
19
trait MailTrait
20
{
21
    use BaseMailTrait;
22
23
    /**
24
     * @var string
25
     */
26
    protected static $mailDir = 'tmp/mail';
27
28
    /**
29
     * Returns mail directory
30
     *
31
     * @return string
32
     */
33
    protected function getMailDir()
34
    {
35
        return $this::$mailDir;
36
    }
37
38
    /**
39
     * Creates temporary mail directory
40
     */
41
    protected function setUpMailDir()
42
    {
43
        is_dir($this::$mailDir) or mkdir($this->getMailDir(), 0777, true);
44
        $this->cleanMail();
45
    }
46
47
    /**
48
     * Cleans up temporary mail directory
49
     */
50
    protected function tearDownMailDir()
51
    {
52
        $this->cleanMail();
53
        is_dir($this->getMailDir()) and @rmdir($this->getMailDir());
54
    }
55
56
    /**
57
     * Remove all mail files
58
     */
59
    protected function cleanMail()
60
    {
61
        foreach ($this->createMailDirIterator() as $fileInfo) {
62
            $path = $fileInfo->getPathname();
63
            unlink($path);
64
        }
65
    }
66
}
67