ElevforeningenUser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hasModuleAccess() 0 4 1
1
<?php
2
require('/home/intraface/intraface.dk/config.local.php');
3
4
require_once 'Intraface/Kernel.php';
5
require_once 'Intraface/Intranet.php';
6
require_once 'Intraface/User.php';
7
require_once 'Intraface/Setting.php';
8
9
class ElevforeningenIntranet extends Intraface_Intranet
10
{
11
    private $intranet_id = 9;
12
13
    function __construct()
14
    {
15
        parent::__construct($this->intranet_id);
16
    }
17
18
    function hasModuleAccess()
19
    {
20
        return true;
21
    }
22
}
23
24
class ElevforeningenUser extends Intraface_User
25
{
26
    private $user_id = 2;
27
28
    function __construct()
29
    {
30
        parent::__construct($this->user_id);
31
    }
32
33
    function hasModuleAccess()
34
    {
35
        return true;
36
    }
37
38
}
39
40
$kernel = new Intraface_Kernel;
41
$kernel->intranet = new ElevforeningenIntranet;
42
$kernel->user = new ElevforeningenUser;
43
$kernel->setting = new Intraface_Setting($kernel->intranet->get('id'), $kernel->user->get('id'));
44
$kernel->module('debtor');
45
$kernel->useModule('contact');
46
47
$debtor = new Debtor($kernel, 'order');
48
$debtor->dbquery->setFilter('status', 0);
0 ignored issues
show
Bug introduced by
The property dbquery cannot be accessed from this context as it is declared protected in class Debtor.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
49
foreach ($debtor->getList() as $debtor) {
50
    if ($debtor['payment_online'] <= 0) {
51
        continue;
52
    }
53
54
    echo $debtor['id'] . ' order set as sent';
55
    $d = Debtor::factory($kernel, $debtor['id']);
56
    $d->setStatus('sent');
57
58
    echo 'creating invoice';
59
    $kernel->useModule('invoice');
60
    $invoice = new Invoice($kernel);
61
    $id = $invoice->create($d);
62
63
    echo 'loading invoice';
64
    $invoice = Debtor::factory($kernel, $id);
0 ignored issues
show
Security Bug introduced by
It seems like $id defined by $invoice->create($d) on line 61 can also be of type false; however, Debtor::factory() does only seem to accept integer, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
65
    $invoice->setStatus('sent');
66
67
    echo 'getting online payments';
68
    $onlinepayment = OnlinePayment::factory($kernel);
69
    $onlinepayment->dbquery->setFilter('belong_to', 'invoice');
70
    $onlinepayment->dbquery->setFilter('belong_to_id', $id);
71
    $onlinepayment->dbquery->setFilter('status', 2);
72
73
    echo 'capturing payment';
74
    foreach ($onlinepayment->getList() as $payment) {
75
        $payment = OnlinePayment::factory($kernel, 'id', $payment['id']);
76
        $payment->transactionAction('capture');
77
    }
78
}
79
80
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...