explicit types

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2016-10-31 14:38:41 +01:00
parent a4ea20a259
commit 4c3d18a9fc
No known key found for this signature in database
GPG Key ID: 425003AC385454C5
2 changed files with 11 additions and 6 deletions

View File

@ -92,6 +92,12 @@ class DefaultToken extends Entity implements IToken {
*/
protected $scope;
public function __construct() {
$this->addType('type', 'int');
$this->addType('lastActivity', 'int');
$this->addType('lastCheck', 'int');
}
public function getId() {
return $this->id;
}
@ -122,8 +128,8 @@ class DefaultToken extends Entity implements IToken {
return [
'id' => $this->id,
'name' => $this->name,
'lastActivity' => (int)$this->lastActivity,
'type' => (int)$this->type,
'lastActivity' => $this->lastActivity,
'type' => $this->type,
'scope' => $this->getScopeAsArray()
];
}
@ -161,10 +167,10 @@ class DefaultToken extends Entity implements IToken {
}
public function setScope($scope) {
if (is_string($scope)) {
parent::setScope($scope);
} else {
if (is_array($scope)) {
parent::setScope(json_encode($scope));
} else {
parent::setScope((string)$scope);
}
}
}

View File

@ -122,7 +122,6 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testGetToken() {
$token = '1504445f1524fc801035448a95681a9378ba2e83930c814546c56e5d6ebde221198792fd900c88ed5ead0555780dad1ebce3370d7e154941cd5de87eb419899b';
$token = new DefaultToken();
$token->setUid('user2');
$token->setLoginName('User2');