Install_Helper_Email::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
class Install_Helper_Email {
3
4
    private $kernel;
5
    private $db;
6
7
    public function __construct($kernel, $db)
8
    {
9
        $this->kernel = $kernel;
10
        $this->db = $db;
11
    }
12
13
    public function create()
14
    {
15
        require_once dirname(__FILE__) . '/Contact.php';
16
        $contact = new Install_Helper_Contact($this->kernel, $this->db);
17
        $contact_id = $contact->create();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $contact_id is correct as $contact->create() (which targets Install_Helper_Contact::create()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
19
        require_once 'Intraface/shared/email/Email.php';
20
        $email = new Email($this->kernel);
21
22
        $email->save(array('belong_to' => 1, 'type_id' => 2, 'contact_id' => $contact_id, 'subject' => 'test', 'body' => 'new test!'));
0 ignored issues
show
Documentation introduced by
array('belong_to' => 1, ... 'body' => 'new test!') is of type array<string,integer|nul...ring","body":"string"}>, but the function expects a object<Struct>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
    }
24
}
25
26