Added new models

This commit is contained in:
Cédric Belin
2018-11-02 00:04:16 +01:00
parent 61625a700e
commit a5f84778cd
5 changed files with 503 additions and 0 deletions

43
lib/models/Team.php Normal file
View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Gitea\Models;
/**
* Represents a team in an organization.
*/
class Team {
/**
* @var string The team description.
*/
public $description = '';
/**
* @var int The team identifier.
*/
public $id = -1;
/**
* @var string The team name.
*/
public $name = '';
/**
* @var string The team permission.
*/
public $permission = TeamPermission::NONE;
/**
* Creates a new user from the specified JSON map.
* @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $map): self {
return new static([
'description' => isset($map->description) && is_string($map->description) ? $map->description : '',
'id' => isset($map->id) && is_int($map->id) ? $map->id : -1,
'name' => isset($map->name) && is_string($map->name) ? $map->name : '',
'permission' => isset($map->permission) && TeamPermission::isDefined($map->permission) ? $map->permission : TeamPermission::NONE
]);
}
}