Completed
Push — master ( a51bc6...a36578 )
by Rafael
03:14
created

Game::getVisitor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Tests\Fixtures\NameSpace1;
11
12
use Rafrsr\LibArray2Object\Array2ObjectBuilder;
13
use Rafrsr\LibArray2Object\Array2ObjectInterface;
14
use Rafrsr\LibArray2Object\Object2ArrayInterface;
15
use Rafrsr\LibArray2Object\Tests\Fixtures\Team;
16
17
class Game implements Array2ObjectInterface, Object2ArrayInterface
18
{
19
20
    protected $stadiumName;
21
22
    protected $date;
23
24
    protected $homeClub;
25
26
    protected $visitor;
27
28
    /**
29
     * @return mixed
30
     */
31
    public function getStadiumName()
32
    {
33
        return $this->stadiumName;
34
    }
35
36
    /**
37
     * @param mixed $stadiumName
38
     *
39
     * @return $this
40
     */
41
    public function setStadiumName($stadiumName)
42
    {
43
        $this->stadiumName = $stadiumName;
44
45
        return $this;
46
    }
47
48
    /**
49
     * @return \DateTime
50
     */
51
    public function getDate()
52
    {
53
        return $this->date;
54
    }
55
56
    /**
57
     * @param \DateTime $date
58
     *
59
     * @return $this
60
     */
61
    public function setDate($date)
62
    {
63
        $this->date = $date;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return Team
70
     */
71
    public function getHomeClub()
72
    {
73
        return $this->homeClub;
74
    }
75
76
    /**
77
     * @param Team $homeClub
78
     *
79
     * @return $this
80
     */
81
    public function setHomeClub($homeClub)
82
    {
83
        $this->homeClub = $homeClub;
84
85
        return $this;
86
    }
87
88
    /**
89
     * @return Team
90
     */
91
    public function getVisitor()
92
    {
93
        return $this->visitor;
94
    }
95
96
    /**
97
     * @param Team $visitor
98
     *
99
     * @return $this
100
     */
101
    public function setVisitor($visitor)
102
    {
103
        $this->visitor = $visitor;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @inheritDoc
110
     */
111
    public function __populate(array $data)
112
    {
113
        $this->setDate(new \DateTime($data['date']));
114
        $this->setStadiumName($data['stadium']);
115
116
        $array2Object = Array2ObjectBuilder::create()->build();
117
        $this->setHomeClub($array2Object->createObject(Team::class, $data['homeClub']));
118
        $this->setVisitor($array2Object->createObject(Team::class, $data['visitor']));
119
    }
120
121
    /**
122
     * @inheritDoc
123
     */
124
    public function __toArray()
125
    {
126
        return [
127
            'date' => $this->getDate()->format('Y-m-d'),
128
            'stadium' => $this->getStadiumName(),
129
            'homeClub' => $this->getHomeClub(),
130
            'visitor' => $this->getVisitor(),
131
        ];
132
    }
133
}