PocketMine-MP 5.35.1 git-09f4626fa630fccbe1d56a65a90ff8f3566e4db8
Loading...
Searching...
No Matches
NamedType.php
1<?php
2
3namespace DaveRandom\CallbackValidator\Type;
4
8final class NamedType implements BaseType{
9
10 public readonly string|BuiltInType $type;
11
12 public function __construct(
13 string|BuiltInType $type,
14 ){
15 //try to convert a string to a BuiltInTypes enum
16 if(is_string($type)){
17 $builtInType = BuiltInType::tryFrom($type);
18 $this->type = $builtInType ?? $type;
19 }else{
20 $this->type = $type;
21 }
22 }
23
24 public function stringify(int $depth = 0) : string{
25 return $this->type instanceof BuiltInType ? $this->type->value : $this->type;
26 }
27}