Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 54
CommentDataMutable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 14
1806
0.00% covered (danger)
0.00%
0 / 54
 __construct
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 13
 fromArray
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 9
 fromIterable
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 10
 getId
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getPostId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getContent
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getPublishedAt
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getAuthorId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 get
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 7
 setId
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 setPostId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setContent
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setPublishedAt
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setAuthorId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php declare(strict_types = 1);
//
// Generated by Smalldb\CodeCooker\Generator\DtoGenerator.
// Do NOT edit! All changes will be lost!
// 
// 
namespace Smalldb\StateMachine\Test\Example\Comment\CommentData;
use DateTimeImmutable;
use InvalidArgumentException;
use Smalldb\CodeCooker\Annotation\GeneratedClass;
use Smalldb\StateMachine\Test\Example\Comment\CommentProperties as Source_CommentProperties;
/**
 * @GeneratedClass
 * @see \Smalldb\StateMachine\Test\Example\Comment\CommentProperties
 */
class CommentDataMutable extends Source_CommentProperties implements CommentData
{
    public function __construct(?CommentData $source = null)
    {
        if ($source !== null) {
            if ($source instanceof Source_CommentProperties) {
                $this->id = $source->id;
                $this->postId = $source->postId;
                $this->content = $source->content;
                $this->publishedAt = $source->publishedAt;
                $this->authorId = $source->authorId;
            } else {
                $this->id = $source->getId();
                $this->postId = $source->getPostId();
                $this->content = $source->getContent();
                $this->publishedAt = $source->getPublishedAt();
                $this->authorId = $source->getAuthorId();
            }
        }
    }
    public static function fromArray(?array $source, ?CommentData $sourceObj = null): ?self
    {
        if ($source === null) {
            return null;
        }
        $t = $sourceObj instanceof self ? clone $sourceObj : new self($sourceObj);
        $t->id = isset($source['id']) ? (int) $source['id'] : null;
        $t->postId = (int) $source['postId'];
        $t->content = (string) $source['content'];
        $t->publishedAt = ($v = $source['publishedAt'] ?? null) instanceof \DateTimeImmutable || $v === null ? $v : ($v instanceof \DateTime ? \DateTimeImmutable::createFromMutable($v) : new \DateTimeImmutable($v));
        $t->authorId = (int) $source['authorId'];
        return $t;
    }
    public static function fromIterable(?CommentData $sourceObj, iterable $source): self
    {
        $t = $sourceObj instanceof self ? clone $sourceObj : new self($sourceObj);
        foreach ($source as $prop => $value) {
            switch ($prop) {
                case 'id': $t->id = $value; break;
                case 'postId': $t->postId = $value; break;
                case 'content': $t->content = $value; break;
                case 'publishedAt': $t->publishedAt = $value instanceof \DateTime ? \DateTimeImmutable::createFromMutable($value) : $value; break;
                case 'authorId': $t->authorId = $value; break;
                default: throw new InvalidArgumentException('Unknown property: "' . $prop . '" not in ' . __CLASS__);
            }
        }
        return $t;
    }
    public function getId(): ?int
    {
        return $this->id;
    }
    public function getPostId(): int
    {
        return $this->postId;
    }
    public function getContent(): string
    {
        return $this->content;
    }
    public function getPublishedAt(): DateTimeImmutable
    {
        return $this->publishedAt;
    }
    public function getAuthorId(): int
    {
        return $this->authorId;
    }
    public static function get(CommentData $source, string $propertyName)
    {
        switch ($propertyName) {
            case 'id': return $source->getId();
            case 'postId': return $source->getPostId();
            case 'content': return $source->getContent();
            case 'publishedAt': return $source->getPublishedAt();
            case 'authorId': return $source->getAuthorId();
            default: throw new \InvalidArgumentException("Unknown property: " . $propertyName);
        }
    }
    public function setId(?int $id): void
    {
        $this->id = $id;
    }
    public function setPostId(int $postId): void
    {
        $this->postId = $postId;
    }
    public function setContent(string $content): void
    {
        $this->content = $content;
    }
    public function setPublishedAt(DateTimeImmutable $publishedAt): void
    {
        $this->publishedAt = $publishedAt;
    }
    public function setAuthorId(int $authorId): void
    {
        $this->authorId = $authorId;
    }
}