Install_Helper_Debtor::createOrder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 21
loc 21
rs 9.3142
c 0
b 0
f 0
1
<?php
2
class Install_Helper_Debtor
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 View Code Duplication
    public function createInvoice()
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...
14
    {
15
        require_once dirname (__FILE__) . '/Contact.php';
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
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 dirname(__FILE__) . '/Product.php';
20
        $product = new Install_Helper_Product($this->kernel, $this->db);
21
        $product_id = $product->create();
22
23
        require_once 'Intraface/modules/invoice/Invoice.php';
24
        $debtor = new Invoice($this->kernel);
25
        $id = $debtor->update(array(
0 ignored issues
show
Unused Code introduced by
$id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
            'contact_id' => $contact_id,
27
            'description' => 'Test invoice',
28
            'this_date' => date('d-m-Y'),
29
            'due_date' => date('d-m-Y', time()+14*60*60*24)));
30
31
        $debtor->loadItem();
32
        $debtor->item->save(array('product_id' => $product_id, 'quantity' => 3, 'description' => 'Test description on product'));
0 ignored issues
show
Bug introduced by
The property item does not seem to exist in Invoice.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
33
    }
34
35 View Code Duplication
    public function createOrder()
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...
36
    {
37
        require_once dirname(__FILE__) . '/Contact.php';
38
        $contact = new Install_Helper_Contact($this->kernel, $this->db);
39
        $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...
40
41
        require_once dirname(__FILE__) . '/Product.php';
42
        $product = new Install_Helper_Product($this->kernel, $this->db);
43
        $product_id = $product->create();
44
45
        require_once 'Intraface/modules/order/Order.php';
46
        $debtor = new Order($this->kernel);
47
        $id = $debtor->update(array(
0 ignored issues
show
Unused Code introduced by
$id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
48
            'contact_id' => $contact_id,
49
            'description' => 'Test invoice',
50
            'this_date' => date('d-m-Y'),
51
            'due_date' => date('d-m-Y', time()+14*60*60*24)));
52
53
        $debtor->loadItem();
54
        $debtor->item->save(array('product_id' => $product_id, 'quantity' => 3, 'description' => 'Test description on product'));
0 ignored issues
show
Bug introduced by
The property item does not seem to exist in Order.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
55
    }
56
57 View Code Duplication
    public function createOrderFromShop()
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...
58
    {
59
        require_once dirname(__FILE__) . '/Contact.php';
60
        $contact = new Install_Helper_Contact($this->kernel, $this->db);
61
        $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...
62
63
        require_once dirname(__FILE__) . '/Product.php';
64
        $product = new Install_Helper_Product($this->kernel, $this->db);
65
        $product_id = $product->create();
66
67
        require_once 'Intraface/modules/order/Order.php';
68
        $debtor = new Order($this->kernel);
69
        $id = $debtor->update(array(
0 ignored issues
show
Unused Code introduced by
$id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
70
            'contact_id' => $contact_id,
71
            'description' => 'From shop',
72
            'this_date' => date('d-m-Y'),
73
            'due_date' => date('d-m-Y', time()+14*60*60*24)), 'webshop', 1);
74
75
        $debtor->loadItem();
76
        $debtor->item->save(array('product_id' => $product_id, 'quantity' => 3, 'description' => 'Test description on product'));
0 ignored issues
show
Bug introduced by
The property item does not seem to exist in Order.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
77
78
    }
79
}
80