-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7 added getTimegridUnits to the core methods
- Loading branch information
1 parent
c72fd76
commit 191baed
Showing
5 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,11 @@ | |
use Webuntis\Models\Interfaces\AdministrativeModelInterface; | ||
use JMS\Serializer\Annotation\SerializedName; | ||
|
||
/** | ||
* StatusData Model | ||
* @author Tobias Franek <[email protected]> | ||
* @license MIT | ||
*/ | ||
class StatusData extends AbstractModel implements CachableModelInterface, AdministrativeModelInterface | ||
{ | ||
const CACHE_LIFE_TIME = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace Webuntis\Models; | ||
|
||
use Webuntis\Models\AbstractModel; | ||
use Webuntis\Models\Interfaces\CachableModelInterface; | ||
use Webuntis\Models\Interfaces\AdministrativeModelInterface; | ||
use JMS\Serializer\Annotation\SerializedName; | ||
|
||
/** | ||
* TimegridUntits Model | ||
* @author Tobias Franek <[email protected]> | ||
* @license MIT | ||
*/ | ||
class TimegridUnits extends AbstractModel implements CachableModelInterface, AdministrativeModelInterface | ||
{ | ||
const CACHE_LIFE_TIME = 0; | ||
const METHOD = "getTimegridUnits"; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $day; | ||
|
||
/** | ||
* @var array | ||
* @SerializedName("timeUnits") | ||
*/ | ||
private $timeUnits; | ||
|
||
/** | ||
* Getter for day | ||
* | ||
* @return int | ||
*/ | ||
public function getDay() : int | ||
{ | ||
return $this->day; | ||
} | ||
|
||
/** | ||
* Setter for day | ||
* | ||
* @param int $day | ||
* | ||
* @return TimegridUnits | ||
*/ | ||
public function setDay(int $day) : self | ||
{ | ||
$this->day = $day; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Getter for timeUnits | ||
* | ||
* @return array | ||
*/ | ||
public function getTimeUnits() : array | ||
{ | ||
return $this->timeUnits; | ||
} | ||
|
||
/** | ||
* Setter for timeUnits | ||
* | ||
* @param array $timeUnits | ||
* | ||
* @return TimegridUnits | ||
*/ | ||
public function setTimeUnits(array $timeUnits) : self | ||
{ | ||
$this->timeUnits = $timeUnits; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* sets an given field | ||
* | ||
* @param mixed $field | ||
* @param mixed $value | ||
* | ||
* @return TimegridUnits | ||
*/ | ||
public function set($field, $value) : self | ||
{ | ||
$this->$field = $value; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Webuntis\Models\TimegridUnits: | ||
repositoryClass: null | ||
fields: | ||
day: | ||
type: int | ||
api: | ||
name: day | ||
timeUnits: | ||
type: array | ||
api: | ||
name: timeUnits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webuntis\Tests\Models; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Webuntis\Models\TimegridUnits; | ||
|
||
/** | ||
* TimegridUnitsTest | ||
* @author Tobias Franek <[email protected]> | ||
* @license MIT | ||
*/ | ||
final class TimegridUnitsTest extends TestCase | ||
{ | ||
public function testCreate() : void | ||
{ | ||
$data = [ | ||
'id' => 1, | ||
'day' => 0, | ||
'timeUnits' => [ | ||
'test' => 'test' | ||
] | ||
]; | ||
|
||
$classes = new TimegridUnits($data); | ||
|
||
$this->assertEquals(1, $classes->getId()); | ||
$this->assertEquals(0, $classes->getDay()); | ||
$this->assertEquals([ | ||
'test' => 'test' | ||
], $classes->getTimeUnits()); | ||
|
||
$expected = [ | ||
'id' => 1, | ||
'day' => 0, | ||
'timeUnits' => [ | ||
'test' => 'test' | ||
] | ||
]; | ||
|
||
$this->assertEquals($expected, $classes->serialize()); | ||
} | ||
} |