Intraface_Controller_Payment::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 2
1
<?php
2
class Intraface_Controller_Payment extends k_Component
3
{
4
    protected $template;
5
6
    function __construct(k_TemplateFactory $template)
7
    {
8
        $this->template = $template;
9
    }
10
11
    function renderHtml()
12
    {
13
        if ($this->query('language') == 'da') {
14
            $text[0] = 'Intraface Betaling';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$text was never initialized. Although not strictly required by PHP, it is generally a good practice to add $text = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
15
            $text[1] = 'Du er nu ved at betale for ordre nummer';
16
            $text[2] = 'I alt hæves %s på fra dit kort';
17
            $text[3] = 'Betalingen foretages over Quickpay\'s sikker betalingsserver.';
18
        } else {
19
            $text[0] = 'Intraface Payment';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$text was never initialized. Although not strictly required by PHP, it is generally a good practice to add $text = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
20
            $text[1] = 'You are now about to pay for order number';
21
            $text[2] = '%s is withdrawed from your card';
22
            $text[3] = 'The payment is carried out via Quickpay\'s secure server.';
23
        }
24
25
        $this->document->setTitle('Payment');
26
27
        $tpl = $this->template->create(dirname(__FILE__) . '/templates/payment');
28
        $content = $tpl-render($this, array('text' => $text));
29
        return new k_HtmlResponse($content);
30
    }
31
}
32