Completed
Pull Request — Laravel4 (#36)
by
unknown
10:35
created

BaseContainer::checkIsNullField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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