Skip to content

Commit a5b89b4

Browse files
committed
add method getInstance()
1 parent 7987c22 commit a5b89b4

31 files changed

+89
-0
lines changed

src/Validator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public function __construct(?string $cnkey) {
99
$this->cnkey = $cnkey ?? '';
1010
$this->validate_function = new \SplQueue();
1111
}
12+
public static function getInstance(...$params): static {
13+
return new static(...$params);
14+
}
1215
/**
1316
* 设置为非必须项
1417
*/

src/Validator/AnyString.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(?string $cnkey, int $min_length = 0, int $max_length = 4096)
5+
*/
36
class AnyString extends \Swango\HttpServer\Validator {
47
private int $min_length, $max_length;
58
public function __construct(?string $cnkey, int $min_length = 0, int $max_length = 4096) {

src/Validator/Anything.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(?string $key, &$value)
5+
*/
36
class Anything extends \Swango\HttpServer\Validator {
47
protected function check(?string $key, &$value): void {}
58
public function getCnMsg(): string {

src/Validator/BackedEnum.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance($cnkey, string $enum_class, ?array $valid_array = null)
5+
*/
36
class BackedEnum extends \Swango\HttpServer\Validator {
47
public function __construct($cnkey, protected string $enum_class, protected ?array $valid_array = null) {
58
parent::__construct($cnkey);

src/Validator/BankCard.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance()
5+
*/
36
class BankCard extends Varchar {
47
public function __construct() {
58
parent::__construct('银行卡号', 15, 19);

src/Validator/Boolean.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(?string $cnkey)
5+
*/
36
class Boolean extends \Swango\HttpServer\Validator {
47
public function getCnMsg(): string {
58
if (isset($this->cnmsg))

src/Validator/COI.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance()
5+
*/
36
class COI extends Varchar {
47
public function __construct() {
58
parent::__construct('身份证号', 18, 18);

src/Validator/Date.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(string $cnkey, bool $not_futrue = true)
5+
*/
36
class Date extends Ob {
47
private $not_futrue;
58
public function __construct(string $cnkey, bool $not_futrue = true) {

src/Validator/DateString.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(string $key)
5+
*/
36
class DateString extends Varchar {
47
public function __construct(string $key) {
58
parent::__construct($key, 8, 10);

src/Validator/Double.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
namespace Swango\HttpServer\Validator;
3+
/**
4+
* @method static getInstance(?string $cnkey, ?int $decimal = null, float $min = 0.0, float $max = 2147483647.0)
5+
*/
36
class Double extends \Swango\HttpServer\Validator {
47
private ?int $decimal;
58
private float $min, $max;

0 commit comments

Comments
 (0)