ShopController::actionSellItems()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
class ShopController extends GameController
3
{
4
    public function actionIndex($page = 0)
5
    {
6
        $this->room(Shop::TYPE_ITEM, $page, 'buy');
7
    }
8
9
    public function actionBuyBaits($page = 0)
10
    {
11
        $this->room(Shop::TYPE_BAIT, $page, 'buy');
12
    }
13
14
    public function actionSellItems($page = 0)
15
    {
16
        $this->room(Shop::TYPE_ITEM, $page, 'sell');
17
    }
18
19
    public function actionSellBaits($page = 0)
20
    {
21
        $this->room(Shop::TYPE_BAIT, $page, 'sell');
22
    }
23
24
    public function actionMakeSets()
25
    {
26
        $item_id = Yii::app()->request->getPost('item_id', 0);
27
28
        $shop = new Shop;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 12 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
29
        $shop->item_type = Shop::TYPE_PART;
0 ignored issues
show
Bug introduced by
The property item_type cannot be accessed from this context as it is declared private in class Shop.

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...
30
        $shop->fetchSets();
31
32
        try {
33
            if ($item_id) {
34
                $shop->constructItem($item_id);
35
            }
36
37
            if ($shop->success['setSold']) {
0 ignored issues
show
Bug introduced by
The property success cannot be accessed from this context as it is declared private in class Shop.

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...
38
                Yii::app()->user->setFlash('success', 'A felszerelés elkészült!');
39
            }
40
        } catch (CFlashException $e) {
41
            Yii::app()->user->setFlash('error', $e->getMessage());
42
        }
43
44
        $this->render('makesets', [
45
            'list' => $shop->items,
0 ignored issues
show
Bug introduced by
The property items cannot be accessed from this context as it is declared private in class Shop.

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...
46
            ]);
47
    }
48
49
    /**
50
     * @param integer $page
51
     * @param string $transaction
52
     */
53
    private function room($type, $page, $transaction)
54
    {
55
        $item_id = Yii::app()->request->getPost('item_id', 0);
56
        $amount = Yii::app()->request->getPost('amount', 0);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
57
58
        $shop = new Shop;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 12 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
59
        $shop->item_type = $type;
0 ignored issues
show
Bug introduced by
The property item_type cannot be accessed from this context as it is declared private in class Shop.

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...
60
        $shop->page = $page;
0 ignored issues
show
Bug introduced by
The property page cannot be accessed from this context as it is declared private in class Shop.

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...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
61
62
        if ($transaction == 'buy') {
63
            $shop->fetchItems();
64
            //buy selected item
65
            $shop->buyItem($item_id, $amount);
66
        } elseif ($transaction == 'sell') {
67
            $shop->fetchPlayersItems();
68
            //sell selected item
69
            $shop->sellItem($item_id, $amount);
70
        }
71
72
        $this->render($transaction.$type.'s', [
73
            'list' => $shop->items,
0 ignored issues
show
Bug introduced by
The property items cannot be accessed from this context as it is declared private in class Shop.

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...
74
            'pagination' => $shop->pagination,
0 ignored issues
show
Bug introduced by
The property pagination cannot be accessed from this context as it is declared private in class Shop.

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...
75
            'count' => $shop->count,
0 ignored issues
show
Bug introduced by
The property count cannot be accessed from this context as it is declared private in class Shop.

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...
76
            'page_size' => Yii::app()->params['shopItemsPerPage'],
77
            'owned_baits' => $shop->owned_baits,
78
            'owned_items' => $shop->owned_items,
79
            'nextItemsLevel' => $shop->nextItemsLevel,
80
            'page'=>$page,
81
            'transactionId'=>$shop->transactionId,
0 ignored issues
show
Bug introduced by
The property transactionId cannot be accessed from this context as it is declared private in class Shop.

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...
82
            ]);
83
    }
84
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
85