<?php
// This is a autogenerated file:GeneratedClass
class GeneratedClass {
private string $a; // json:a Required
private array $arr; // json:arr Required
private Nested $nested; // json:nested Required
/**
* @param string $a
* @param array $arr
* @param Nested $nested
*/
public function __construct(string $a, array $arr, Nested $nested) {
$this->a = $a;
$this->arr = $arr;
$this->nested = $nested;
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromA(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toA(): string {
if (GeneratedClass::validateA($this->a)) {
return $this->a; /*string*/
}
throw new Exception('never get to this GeneratedClass::a');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateA(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:GeneratedClass::a");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getA(): string {
if (GeneratedClass::validateA($this->a)) {
return $this->a;
}
throw new Exception('never get to getA GeneratedClass::a');
}
/**
* @param string
* @throws Exception
*/
public function setA(string $value) {
if (GeneratedClass::validateA($value)) {
$this->a = $value;
}
}
/**
* @return string
*/
public static function sampleA(): string {
return 'GeneratedClass::a::31'; /*31:a*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromArr(array $value): array {
return array_map(function ($value) {
return $value; /*int*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toArr(): array {
if (GeneratedClass::validateArr($this->arr)) {
return array_map(function ($value) {
return $value; /*int*/
}, $this->arr);
}
throw new Exception('never get to this GeneratedClass::arr');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateArr(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:GeneratedClass::arr");
}
array_walk($value, function($value_v) {
if (!is_integer($value_v)) {
throw new Exception("Attribute Error:GeneratedClass::arr");
}
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getArr(): array {
if (GeneratedClass::validateArr($this->arr)) {
return $this->arr;
}
throw new Exception('never get to getArr GeneratedClass::arr');
}
/**
* @param array
* @throws Exception
*/
public function setArr(array $value) {
if (GeneratedClass::validateArr($value)) {
$this->arr = $value;
}
}
/**
* @return array
*/
public static function sampleArr(): array {
return array(
32 /*32:*/
); /* 32:arr*/
}
/**
* @param stdClass $value
* @throws Exception
* @return Nested
*/
public static function fromNested(stdClass $value): Nested {
return Nested::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toNested(): stdClass {
if (GeneratedClass::validateNested($this->nested)) {
return $this->nested->to(); /*class*/
}
throw new Exception('never get to this GeneratedClass::nested');
}
/**
* @param Nested
* @return bool
* @throws Exception
*/
public static function validateNested(Nested $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return Nested
*/
public function getNested(): Nested {
if (GeneratedClass::validateNested($this->nested)) {
return $this->nested;
}
throw new Exception('never get to getNested GeneratedClass::nested');
}
/**
* @param Nested
* @throws Exception
*/
public function setNested(Nested $value) {
if (GeneratedClass::validateNested($value)) {
$this->nested = $value;
}
}
/**
* @return Nested
*/
public static function sampleNested(): Nested {
return Nested::sample(); /*33:nested*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return GeneratedClass::validateA($this->a)
|| GeneratedClass::validateArr($this->arr)
|| GeneratedClass::validateNested($this->nested);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'a'} = $this->toA();
$out->{'arr'} = $this->toArr();
$out->{'nested'} = $this->toNested();
return $out;
}
/**
* @param stdClass $obj
* @return GeneratedClass
* @throws Exception
*/
public static function from(stdClass $obj): GeneratedClass {
return new GeneratedClass(
GeneratedClass::fromA($obj->{'a'})
,GeneratedClass::fromArr($obj->{'arr'})
,GeneratedClass::fromNested($obj->{'nested'})
);
}
/**
* @return GeneratedClass
*/
public static function sample(): GeneratedClass {
return new GeneratedClass(
GeneratedClass::sampleA()
,GeneratedClass::sampleArr()
,GeneratedClass::sampleNested()
);
}
}
// This is a autogenerated file:Nested
class Nested {
private int $a; // json:a Required
private string $b; // json:b Required
/**
* @param int $a
* @param string $b
*/
public function __construct(int $a, string $b) {
$this->a = $a;
$this->b = $b;
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromA(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toA(): int {
if (Nested::validateA($this->a)) {
return $this->a; /*int*/
}
throw new Exception('never get to this Nested::a');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateA(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Nested::a");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getA(): int {
if (Nested::validateA($this->a)) {
return $this->a;
}
throw new Exception('never get to getA Nested::a');
}
/**
* @param int
* @throws Exception
*/
public function setA(int $value) {
if (Nested::validateA($value)) {
$this->a = $value;
}
}
/**
* @return int
*/
public static function sampleA(): int {
return 31; /*31:a*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromB(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toB(): string {
if (Nested::validateB($this->b)) {
return $this->b; /*string*/
}
throw new Exception('never get to this Nested::b');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateB(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Nested::b");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getB(): string {
if (Nested::validateB($this->b)) {
return $this->b;
}
throw new Exception('never get to getB Nested::b');
}
/**
* @param string
* @throws Exception
*/
public function setB(string $value) {
if (Nested::validateB($value)) {
$this->b = $value;
}
}
/**
* @return string
*/
public static function sampleB(): string {
return 'Nested::b::32'; /*32:b*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Nested::validateA($this->a)
|| Nested::validateB($this->b);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'a'} = $this->toA();
$out->{'b'} = $this->toB();
return $out;
}
/**
* @param stdClass $obj
* @return Nested
* @throws Exception
*/
public static function from(stdClass $obj): Nested {
return new Nested(
Nested::fromA($obj->{'a'})
,Nested::fromB($obj->{'b'})
);
}
/**
* @return Nested
*/
public static function sample(): Nested {
return new Nested(
Nested::sampleA()
,Nested::sampleB()
);
}
}
?>