Completed
Pull Request — master (#74)
by Ernest
01:33
created

Package::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Syntax\SteamApi\Containers;
4
5
class Package extends BaseContainer
6
{
7
    public $id;
8
    public $name;
9
    public $page_image;
10
    public $header;
11
    public $small_logo;
12
    public $apps;
13
    public $page_content;
14
    public $price;
15
    public $platforms;
16
    public $release;
17
18
    public function __construct($package, $id)
19
    {
20
        $this->id = (int) $id;
21
        $this->name = $package->name;
22
        $this->apps = $package->apps;
23
        $this->page_content = $this->checkIssetField($package, 'page_content', 'none');
24
        $this->header = $this->checkIssetField($package, 'header_image', 'none');
25
        $this->small_logo = $this->checkIssetField($package, 'small_logo', 'none');
26
        $this->page_image = $this->checkIssetField($package, 'page_image', 'none');
27
        $this->price = $this->formatPriceObject($package, 'price');
0 ignored issues
show
Bug introduced by
The method formatPriceObject() does not seem to exist on object<Syntax\SteamApi\Containers\Package>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
        $this->platforms = $package->platforms;
29
        $this->controller = $package->controller;
0 ignored issues
show
Bug introduced by
The property controller does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
        $this->release = $package->release_date;
31
    }
32
}
33