Added an example code

This commit is contained in:
Cédric Belin
2018-11-02 00:03:45 +01:00
parent 3891e435c1
commit 3ffe5d6b9c
6 changed files with 27 additions and 58 deletions

View File

@ -1,17 +1,16 @@
<?php
declare(strict_types=1);
namespace yii\gitea\models;
namespace Gitea\Models;
use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface};
use yii\base\{Model};
/**
* Represents a commit.
* @property \DateTime|null $timestamp The commit date.
* @property UriInterface|null $url The URL to the commit's history.
*/
class PayloadCommit extends Model {
class PayloadCommit {
/**
* @var PayloadUser|null The person who authored the commit.
@ -97,16 +96,6 @@ class PayloadCommit extends Model {
return $this->url;
}
/**
* Returns the validation rules for attributes.
* @return array[] The validation rules.
*/
function rules(): array {
return [
[['id', 'message'], 'trim']
];
}
/**
* Sets the commit date.
* @param \DateTime|string|null $value The new commit date.

View File

@ -1,13 +1,11 @@
<?php
declare(strict_types=1);
namespace yii\gitea\models;
use yii\base\{Model};
namespace Gitea\Models;
/**
* Represents the GPG verification of a commit.
*/
class PayloadCommitVerification extends Model {
class PayloadCommitVerification {
/**
* @var bool Value indicating whether the verification has succeeded.
@ -55,15 +53,4 @@ class PayloadCommitVerification extends Model {
'verified' => 'isVerified'
];
}
/**
* Returns the validation rules for attributes.
* @return array[] The validation rules.
*/
function rules(): array {
return [
[['payload', 'reason', 'signature'], 'trim'],
['isVerified', 'boolean', 'falseValue' => false, 'trueValue' => true]
];
}
}

View File

@ -1,13 +1,11 @@
<?php
declare(strict_types=1);
namespace yii\gitea\models;
use yii\base\{Model};
namespace Gitea\Models;
/**
* Represents the author or committer of a commit.
*/
class PayloadUser extends Model {
class PayloadUser {
/**
* @var string The mail address.
@ -36,16 +34,4 @@ class PayloadUser extends Model {
'username' => isset($map->username) && is_string($map->username) ? $map->username : ''
]);
}
/**
* Returns the validation rules for attributes.
* @return array[] The validation rules.
*/
function rules(): array {
return [
[['email', 'name', 'username'], 'trim'],
['email', 'filter', 'filter' => 'mb_strtolower'],
['email', 'email']
];
}
}

View File

@ -1,13 +1,11 @@
<?php
declare(strict_types=1);
namespace yii\gitea\models;
use yii\base\{Model};
namespace Gitea\Models;
/**
* Represents a set of permissions.
*/
class Permission extends Model {
class Permission {
/**
* @var bool Value indicating whether administrator access is allowed.
@ -36,14 +34,4 @@ class Permission extends Model {
'push' => isset($map->push) && is_bool($map->push) ? $map->push : false
]);
}
/**
* Returns the validation rules for attributes.
* @return array[] The validation rules.
*/
function rules(): array {
return [
[['admin', 'pull', 'push'], 'boolean', 'falseValue' => false, 'trueValue' => true]
];
}
}