-
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.
- Loading branch information
1 parent
0532443
commit c72fd76
Showing
5 changed files
with
175 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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Webuntis\Models; | ||
|
||
use Webuntis\Models\AbstractModel; | ||
use Webuntis\Models\Interfaces\CachableModelInterface; | ||
use Webuntis\Models\Interfaces\AdministrativeModelInterface; | ||
use JMS\Serializer\Annotation\SerializedName; | ||
|
||
class StatusData extends AbstractModel implements CachableModelInterface, AdministrativeModelInterface | ||
{ | ||
const CACHE_LIFE_TIME = 0; | ||
const METHOD = "getStatusData"; | ||
|
||
/** | ||
* @var array | ||
* @SerializedName("lessonTypes") | ||
*/ | ||
private $lessonTypes; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $codes; | ||
|
||
/** | ||
* Getter for lessonTypes | ||
* | ||
* @return array | ||
*/ | ||
public function getLessonTypes() : array | ||
{ | ||
return $this->lessonTypes; | ||
} | ||
|
||
/** | ||
* Setter for lessonTypes | ||
* | ||
* @param array $lessonTypes | ||
* | ||
* @return StatusData | ||
*/ | ||
public function setLessonTypes(array $lessonTypes) : self | ||
{ | ||
$this->lessonTypes = $lessonTypes; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Getter for codes | ||
* | ||
* @return array | ||
*/ | ||
public function getCodes() : array | ||
{ | ||
return $this->codes; | ||
} | ||
|
||
/** | ||
* Setter for codes | ||
* | ||
* @param array $codes | ||
* | ||
* @return StatusData | ||
*/ | ||
public function setCodes(array $codes) : self | ||
{ | ||
$this->codes = $codes; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* sets an given field | ||
* | ||
* @param mixed $field | ||
* @param mixed $value | ||
* | ||
* @return StatusData | ||
*/ | ||
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,23 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webuntis\Repositories; | ||
use Webuntis\Models\Schoolyears; | ||
use Webuntis\Models\CurrentSchoolyear; | ||
use Webuntis\Handler\ExecutionHandler; | ||
|
||
/** | ||
* StatusDataRepository | ||
* @author Tobias Franek <[email protected]> | ||
* @license MIT | ||
*/ | ||
class StatusDataRepository extends Repository { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function parse(array $result) : array | ||
{ | ||
return [new $this->model($result)]; | ||
} | ||
} |
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\StatusData: | ||
repositoryClass: Webuntis\Repositories\StatusDataRepository | ||
fields: | ||
lessonTypes: | ||
type: array | ||
api: | ||
name: lstypes | ||
codes: | ||
type: array | ||
api: | ||
name: codes |
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,50 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Webuntis\Tests\Models; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Webuntis\Models\StatusData; | ||
|
||
/** | ||
* StatusDataTest | ||
* @author Tobias Franek <[email protected]> | ||
* @license MIT | ||
*/ | ||
final class StatusDataTest extends TestCase | ||
{ | ||
public function testCreate() : void | ||
{ | ||
$data = [ | ||
'id' => 1, | ||
'lstypes' => [ | ||
'test' => 'test' | ||
], | ||
'codes' => [ | ||
'test' => 'test' | ||
] | ||
]; | ||
|
||
$classes = new StatusData($data); | ||
|
||
$this->assertEquals(1, $classes->getId()); | ||
$this->assertEquals([ | ||
'test' => 'test' | ||
], $classes->getLessonTypes()); | ||
$this->assertEquals([ | ||
'test' => 'test' | ||
], $classes->getCodes()); | ||
|
||
$expected = [ | ||
'id' => 1, | ||
'lessonTypes' => [ | ||
'test' => 'test' | ||
], | ||
'codes' => [ | ||
'test' => 'test' | ||
] | ||
]; | ||
|
||
$this->assertEquals($expected, $classes->serialize()); | ||
} | ||
} |