Created
December 9, 2018 05:02
-
-
Save o0h/0cd23ead77e756ec1c1ad0caa92a8a66 to your computer and use it in GitHub Desktop.
cakephp-dtoプラグインお試し
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* !!! Auto generated file. Do not directly modify this file. !!! | |
* You can either version control this or generate the file on the fly prior to usage/deployment. | |
*/ | |
namespace App\Dto; | |
/** | |
* Car DTO | |
*/ | |
class CarDto extends \CakeDto\Dto\AbstractDto { | |
const FIELD_IS_NEW = 'isNew'; | |
const FIELD_VALUE = 'value'; | |
const FIELD_DISTANCE_TRAVELLED = 'distanceTravelled'; | |
const FIELD_ATTRIBUTES = 'attributes'; | |
const FIELD_MANUFACTURED = 'manufactured'; | |
const FIELD_OWNER = 'owner'; | |
/** | |
* @var bool|null | |
*/ | |
protected $isNew; | |
/** | |
* @var float|null | |
*/ | |
protected $value; | |
/** | |
* @var int|null | |
*/ | |
protected $distanceTravelled; | |
/** | |
* @var string[]|null | |
*/ | |
protected $attributes; | |
/** | |
* @var \Cake\I18n\FrozenDate|null | |
*/ | |
protected $manufactured; | |
/** | |
* @var OwnerDto|null | |
*/ | |
protected $owner; | |
/** | |
* Some data is only for debugging for now. | |
* | |
* @var array | |
*/ | |
protected $_metadata = [ | |
'isNew' => [ | |
'type' => 'bool', | |
'name' => 'isNew', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => false, | |
'class' => null, | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
'value' => [ | |
'type' => 'float', | |
'name' => 'value', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => false, | |
'class' => null, | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
'distanceTravelled' => [ | |
'type' => 'int', | |
'name' => 'distanceTravelled', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => false, | |
'class' => null, | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
'attributes' => [ | |
'type' => 'string[]', | |
'name' => 'attributes', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => false, | |
'class' => null, | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
'manufactured' => [ | |
'type' => '\Cake\I18n\FrozenDate', | |
'name' => 'manufactured', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => false, | |
'class' => '\Cake\I18n\FrozenDate', | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
'owner' => [ | |
'type' => 'OwnerDto', | |
'name' => 'owner', | |
'required' => false, | |
'defaultValue' => null, | |
'isDto' => true, | |
'class' => '\App\Dto\OwnerDto', | |
'singularClass' => null, | |
'collectionType' => null, | |
'associative' => false, | |
'serializable' => false, | |
'toArray' => false, | |
], | |
]; | |
/** | |
* @var array | |
*/ | |
protected $_keyMap = [ | |
'underscored' => [ | |
'is_new' => 'isNew', | |
'value' => 'value', | |
'distance_travelled' => 'distanceTravelled', | |
'attributes' => 'attributes', | |
'manufactured' => 'manufactured', | |
'owner' => 'owner', | |
], | |
'dashed' => [ | |
'is-new' => 'isNew', | |
'value' => 'value', | |
'distance-travelled' => 'distanceTravelled', | |
'attributes' => 'attributes', | |
'manufactured' => 'manufactured', | |
'owner' => 'owner', | |
], | |
]; | |
/** | |
* @param bool|null $isNew | |
* | |
* @return $this | |
*/ | |
public function setIsNew(?bool $isNew = null) { | |
$this->isNew = $isNew; | |
$this->_touchedFields[self::FIELD_IS_NEW] = true; | |
return $this; | |
} | |
/** | |
* @return bool|null | |
*/ | |
public function getIsNew(): ?bool { | |
return $this->isNew; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return bool | |
*/ | |
public function getIsNewOrFail(): bool { | |
if (!isset($this->isNew)) { | |
throw new \RuntimeException('Value not set for field `isNew` (expected to be not null)'); | |
} | |
return $this->isNew; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasIsNew() { | |
return $this->isNew !== null; | |
} | |
/** | |
* @param float|null $value | |
* | |
* @return $this | |
*/ | |
public function setValue(?float $value = null) { | |
$this->value = $value; | |
$this->_touchedFields[self::FIELD_VALUE] = true; | |
return $this; | |
} | |
/** | |
* @return float|null | |
*/ | |
public function getValue(): ?float { | |
return $this->value; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return float | |
*/ | |
public function getValueOrFail(): float { | |
if (!isset($this->value)) { | |
throw new \RuntimeException('Value not set for field `value` (expected to be not null)'); | |
} | |
return $this->value; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasValue() { | |
return $this->value !== null; | |
} | |
/** | |
* @param int|null $distanceTravelled | |
* | |
* @return $this | |
*/ | |
public function setDistanceTravelled(?int $distanceTravelled = null) { | |
$this->distanceTravelled = $distanceTravelled; | |
$this->_touchedFields[self::FIELD_DISTANCE_TRAVELLED] = true; | |
return $this; | |
} | |
/** | |
* @return int|null | |
*/ | |
public function getDistanceTravelled(): ?int { | |
return $this->distanceTravelled; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return int | |
*/ | |
public function getDistanceTravelledOrFail(): int { | |
if (!isset($this->distanceTravelled)) { | |
throw new \RuntimeException('Value not set for field `distanceTravelled` (expected to be not null)'); | |
} | |
return $this->distanceTravelled; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasDistanceTravelled() { | |
return $this->distanceTravelled !== null; | |
} | |
/** | |
* @param string[]|null $attributes | |
* | |
* @return $this | |
*/ | |
public function setAttributes(?array $attributes = null) { | |
$this->attributes = $attributes; | |
$this->_touchedFields[self::FIELD_ATTRIBUTES] = true; | |
return $this; | |
} | |
/** | |
* @return string[]|null | |
*/ | |
public function getAttributes(): ?array { | |
return $this->attributes; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return string[] | |
*/ | |
public function getAttributesOrFail(): array { | |
if (!isset($this->attributes)) { | |
throw new \RuntimeException('Value not set for field `attributes` (expected to be not null)'); | |
} | |
return $this->attributes; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasAttributes() { | |
return $this->attributes !== null; | |
} | |
/** | |
* @param \Cake\I18n\FrozenDate|null $manufactured | |
* | |
* @return $this | |
*/ | |
public function setManufactured(?\Cake\I18n\FrozenDate $manufactured = null) { | |
$this->manufactured = $manufactured; | |
$this->_touchedFields[self::FIELD_MANUFACTURED] = true; | |
return $this; | |
} | |
/** | |
* @return \Cake\I18n\FrozenDate|null | |
*/ | |
public function getManufactured(): ?\Cake\I18n\FrozenDate { | |
return $this->manufactured; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return \Cake\I18n\FrozenDate | |
*/ | |
public function getManufacturedOrFail(): \Cake\I18n\FrozenDate { | |
if (!isset($this->manufactured)) { | |
throw new \RuntimeException('Value not set for field `manufactured` (expected to be not null)'); | |
} | |
return $this->manufactured; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasManufactured() { | |
return $this->manufactured !== null; | |
} | |
/** | |
* @param OwnerDto|null $owner | |
* | |
* @return $this | |
*/ | |
public function setOwner(?OwnerDto $owner = null) { | |
$this->owner = $owner; | |
$this->_touchedFields[self::FIELD_OWNER] = true; | |
return $this; | |
} | |
/** | |
* @return OwnerDto|null | |
*/ | |
public function getOwner(): ?OwnerDto { | |
return $this->owner; | |
} | |
/** | |
* @throws \RuntimeException If value is not set. | |
* | |
* @return OwnerDto | |
*/ | |
public function getOwnerOrFail(): OwnerDto { | |
if (!isset($this->owner)) { | |
throw new \RuntimeException('Value not set for field `owner` (expected to be not null)'); | |
} | |
return $this->owner; | |
} | |
/** | |
* @return bool | |
*/ | |
public function hasOwner() { | |
return $this->owner !== null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment