Mail_model   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A sendmail() 0 25 2
1
<?php
2
3
/**
4
 * @property CI_Email $email
5
 */
6
class Mail_model extends CI_Model {
7
8
	public function __construct()
9
	{
10
		parent::__construct();
11
		$this->load->library('email');
0 ignored issues
show
Documentation introduced by
The property load does not exist on object<Mail_model>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
12
	}
13
14
	/**
15
	 * メール送信処理
16
	 * 
17
	 * @param array $mail
18
	 * @return boolean
19
	 */
20
	public function sendmail($mail)
21
	{
22
# Emailクラスを初期化します。
23
		$config = [];
24
		$config['protocol'] = 'mail';
25
		$config['wordwrap'] = FALSE;
26
		$this->email->initialize($config);
27
28
# 差出人、あて先、Bcc、件名、本文を設定します。
29
		$this->email->from($mail['from'], $mail['from_name']);
30
		$this->email->to($mail['to']);
31
		$this->email->bcc($mail['bcc']);
32
		$this->email->subject($mail['subject']);
33
		$this->email->message($mail['body']);
34
35
# send()メソッドで実際にメールを送信します。
36
		if ($this->email->send())
37
		{
38
			return TRUE;
39
		}
40
		else
41
		{
42
			return FALSE;
43
		}
44
	}
45
46
}
47