Skip to content

Commit

Permalink
update gen
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Nov 11, 2023
1 parent 1e6317f commit f28e4a9
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 28 deletions.
16 changes: 12 additions & 4 deletions src/Model/DiscoveryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class DiscoveryCollection implements \JsonSerializable
class DiscoveryCollection implements \JsonSerializable, \PSX\Record\RecordableInterface
{
/**
* @var array<DiscoveryLink>|null
Expand All @@ -18,15 +18,23 @@ public function setLinks(?array $links) : void
{
$this->links = $links;
}
/**
* @return array<DiscoveryLink>|null
*/
public function getLinks() : ?array
{
return $this->links;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('links', $this->links);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('links' => $this->links), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

15 changes: 11 additions & 4 deletions src/Model/DiscoveryLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class DiscoveryLink implements \JsonSerializable
class DiscoveryLink implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $rel = null;
protected ?string $href = null;
Expand Down Expand Up @@ -34,11 +34,18 @@ public function getMethod() : ?string
{
return $this->method;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('rel', $this->rel);
$record->put('href', $this->href);
$record->put('method', $this->method);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('rel' => $this->rel, 'href' => $this->href, 'method' => $this->method), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

17 changes: 13 additions & 4 deletions src/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PSX\Schema\Attribute\Key;

#[Description('File upload provided through a multipart/form-data post')]
class File implements \JsonSerializable
class File implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $name = null;
protected ?string $type = null;
Expand Down Expand Up @@ -56,11 +56,20 @@ public function getError() : ?int
{
return $this->error;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('name', $this->name);
$record->put('type', $this->type);
$record->put('size', $this->size);
$record->put('tmp_name', $this->tmpName);
$record->put('error', $this->error);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('name' => $this->name, 'type' => $this->type, 'size' => $this->size, 'tmp_name' => $this->tmpName, 'error' => $this->error), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

14 changes: 10 additions & 4 deletions src/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class Message implements \JsonSerializable
class Message implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?bool $success = null;
protected ?string $message = null;
Expand All @@ -25,11 +25,17 @@ public function getMessage() : ?string
{
return $this->message;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('success', $this->success);
$record->put('message', $this->message);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('success' => $this->success, 'message' => $this->message), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

16 changes: 12 additions & 4 deletions src/Model/RoutingCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class RoutingCollection implements \JsonSerializable
class RoutingCollection implements \JsonSerializable, \PSX\Record\RecordableInterface
{
/**
* @var array<RoutingRoute>|null
Expand All @@ -18,15 +18,23 @@ public function setRoutings(?array $routings) : void
{
$this->routings = $routings;
}
/**
* @return array<RoutingRoute>|null
*/
public function getRoutings() : ?array
{
return $this->routings;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('routings', $this->routings);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('routings' => $this->routings), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

15 changes: 11 additions & 4 deletions src/Model/RoutingRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class RoutingRoute implements \JsonSerializable
class RoutingRoute implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $method = null;
protected ?string $path = null;
Expand Down Expand Up @@ -34,11 +34,18 @@ public function getOperationId() : ?string
{
return $this->operationId;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('method', $this->method);
$record->put('path', $this->path);
$record->put('operationId', $this->operationId);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('method' => $this->method, 'path' => $this->path, 'operationId' => $this->operationId), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

14 changes: 10 additions & 4 deletions src/Model/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PSX\Framework\Model;


class Welcome implements \JsonSerializable
class Welcome implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $message = null;
protected ?string $url = null;
Expand All @@ -25,11 +25,17 @@ public function getUrl() : ?string
{
return $this->url;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('message', $this->message);
$record->put('url', $this->url);
return $record;
}
public function jsonSerialize() : object
{
return (object) array_filter(array('message' => $this->message, 'url' => $this->url), static function ($value) : bool {
return $value !== null;
});
return (object) $this->toRecord()->getAll();
}
}

0 comments on commit f28e4a9

Please sign in to comment.