Completed
Pull Request — master (#37)
by Mahmoud
08:04
created

BaseContainer::checkIsNullField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 3
crap 6
1
<?php namespace Syntax\SteamApi\Containers;
2
3
use Syntax\SteamApi\Collection;
4
5
abstract class BaseContainer {
6
7
    /**
8
     * @param        $app
9
     * @param string $field
10
     * @param mixed  $value
11
     *
12
     * @return mixed
13
     */
14
    protected function checkIsNullField($app, $field, $value = null)
15
    {
16
        return ! is_null($app->$field) ? $app->$field : $value;
17
    }
18
19
    /**
20
     * @param        $app
21
     * @param string $field
22
     * @param mixed  $value
23
     *
24
     * @return mixed
25
     */
26
    protected function checkIssetField($app, $field, $value = null)
27
    {
28
        return isset($app->$field) ? $app->$field : $value;
29
    }
30
31
    /**
32
     * @param        $app
33
     * @param string $field
34
     * @param mixed  $value
35
     *
36
     * @return mixed
37
     */
38
    protected function checkIssetCollection($app, $field, $value = null)
39
    {
40
        return isset($app->$field) ? new Collection($app->$field) : $value;
41
    }
42
43
    /**
44
     * @param string $image
45
     *
46
     * @return string
47
     */
48 2
    protected function getImageForAvatar($image)
49
    {
50 2
        return '<img src="' . $image . '" />';
51
    }
52
53
}