Completed
Push — master ( 716e15...7881d6 )
by Cheren
02:20
created

Email   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 18
loc 60
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A sendActivationMessage() 9 9 1
A sendCreateMessage() 9 9 1
A _initialize() 0 4 1
A _getFromMail() 0 4 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
/**
3
 * CakeCMS Community
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package     Community
10
 * @license     MIT
11
 * @copyright   MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link        https://github.com/CakeCMS/Community".
13
 * @author      Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Community\Notify;
17
18
use JBZoo\Data\Data;
19
use Extensions\Plugin;
20
use Core\Utility\Macros;
21
use Community\Model\Entity\User;
22
use Core\Notify\Email as CoreEmail;
23
24
/**
25
 * Class Email
26
 *
27
 * @package  Community\Notify
28
 * @property User $_data
29
 */
30
class Email extends CoreEmail
31
{
32
33
    /**
34
     * Plugin params.
35
     *
36
     * @var Data
37
     */
38
    protected $_params;
39
40
    /**
41
     * Send user message when have success activation profile.
42
     *
43
     * @return  array
44
     */
45 View Code Duplication
    public function sendActivationMessage()
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47
        $macros  = new Macros($this->_data);
48
        $message = $this->_params->get('msg_account_activate_msg');
49
        $message = $macros->text($message);
50
        $subject = $this->_params->get('msg_account_activate_subject');
51
52
        return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail());
53
    }
54
55
    /**
56
     * Send user create account profile message / set password.
57
     *
58
     * @return  array
59
     */
60 View Code Duplication
    public function sendCreateMessage()
0 ignored issues
show
Duplication introduced by
This method 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...
61
    {
62
        $macros  = new Macros($this->_data);
63
        $message = $this->_params->get('msg_account_create_msg');
64
        $message = $macros->text($message);
65
        $subject = $this->_params->get('msg_account_create_subject');
66
67
        return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail());
68
    }
69
70
    /**
71
     * Constructor hook method.
72
     *
73
     * @return  void
74
     */
75
    protected function _initialize()
76
    {
77
        $this->_params = Plugin::getParams('Community');
78
    }
79
80
    /**
81
     * Get from email - global settings.
82
     *
83
     * @return  string
84
     */
85
    protected function _getFromMail()
86
    {
87
        return Plugin::getParams('Core')->get('admin_email');
88
    }
89
}
90