Completed
Push — dev ( b407ba...a6af5b )
by Shingo
24:39
created

MailSettings   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 84
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 84
loc 84
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setBcc() 5 5 1
A setBypassListManagement() 5 5 1
A setFooter() 5 5 1
A setSandboxMode() 5 5 1
A setSpamCheck() 5 5 1
A toArray() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Sichikawa\LaravelSendgridDriver\Api;
3
4
5
use Sichikawa\LaravelSendgridDriver\Api\MailSettings\Bcc;
6
use Sichikawa\LaravelSendgridDriver\Api\MailSettings\BypassListManagement;
7
use Sichikawa\LaravelSendgridDriver\Api\MailSettings\Footer;
8
use Sichikawa\LaravelSendgridDriver\Api\MailSettings\SandboxMode;
9
use Sichikawa\LaravelSendgridDriver\Api\MailSettings\SpamCheck;
10
11 View Code Duplication
class MailSettings
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var Bcc
15
     */
16
    public $bcc;
17
18
    /**
19
     * @var BypassListManagement
20
     */
21
    public $bypass_list_management;
22
23
    /**
24
     * @var Footer
25
     */
26
    public $footer;
27
28
    /**
29
     * @var SandboxMode
30
     */
31
    public $sandbox_mode;
32
33
    /**
34
     * @var SpamCheck
35
     */
36
    public $spam_check;
37
38
    /**
39
     * @param Bcc $bcc
40
     * @return MailSettings
41
     */
42
    public function setBcc($bcc)
43
    {
44
        $this->bcc = $bcc;
45
        return $this;
46
    }
47
48
    /**
49
     * @param BypassListManagement $bypass_list_management
50
     * @return MailSettings
51
     */
52
    public function setBypassListManagement($bypass_list_management)
53
    {
54
        $this->bypass_list_management = $bypass_list_management;
55
        return $this;
56
    }
57
58
    /**
59
     * @param Footer $footer
60
     * @return MailSettings
61
     */
62
    public function setFooter($footer)
63
    {
64
        $this->footer = $footer;
65
        return $this;
66
    }
67
68
    /**
69
     * @param SandboxMode $sandbox_mode
70
     * @return MailSettings
71
     */
72
    public function setSandboxMode($sandbox_mode)
73
    {
74
        $this->sandbox_mode = $sandbox_mode;
75
        return $this;
76
    }
77
78
    /**
79
     * @param SpamCheck $spam_check
80
     * @return MailSettings
81
     */
82
    public function setSpamCheck($spam_check)
83
    {
84
        $this->spam_check = $spam_check;
85
        return $this;
86
    }
87
88
    public function toArray()
89
    {
90
        return array_filter(json_decode(json_encode($this), true), function ($val) {
91
            return !empty($val);
92
        });
93
    }
94
}