Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
40.00% covered (danger)
40.00%
4 / 10
CRAP
33.33% covered (danger)
33.33%
11 / 33
TagDataMutable
0.00% covered (danger)
0.00%
0 / 1
40.00% covered (danger)
40.00%
4 / 10
260.30
33.33% covered (danger)
33.33%
11 / 33
 __construct
0.00% covered (danger)
0.00%
0 / 1
4.37
71.43% covered (warning)
71.43%
5 / 7
 fromArray
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 6
 fromIterable
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 7
 getId
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 get
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 4
 setId
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
2 / 2
 setName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 setNameFromSlug
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 resetName
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\Tag\TagData;
use InvalidArgumentException;
use Smalldb\CodeCooker\Annotation\GeneratedClass;
use Smalldb\StateMachine\Test\Example\Tag\TagProperties as Source_TagProperties;
/**
 * @GeneratedClass
 * @see \Smalldb\StateMachine\Test\Example\Tag\TagProperties
 */
class TagDataMutable extends Source_TagProperties implements TagData
{
    public function __construct(?TagData $source = null)
    {
        if ($source !== null) {
            if ($source instanceof Source_TagProperties) {
                $this->id = $source->id;
                $this->name = $source->name;
            } else {
                $this->id = $source->getId();
                $this->name = $source->getName();
            }
        }
    }
    public static function fromArray(?array $source, ?TagData $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->name = (string) $source['name'];
        return $t;
    }
    public static function fromIterable(?TagData $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 'name': $t->name = $value; break;
                default: throw new InvalidArgumentException('Unknown property: "' . $prop . '" not in ' . __CLASS__);
            }
        }
        return $t;
    }
    public function getId(): ?int
    {
        return $this->id;
    }
    public function getName(): string
    {
        return $this->name;
    }
    public static function get(TagData $source, string $propertyName)
    {
        switch ($propertyName) {
            case 'id': return $source->getId();
            case 'name': return $source->getName();
            default: throw new \InvalidArgumentException("Unknown property: " . $propertyName);
        }
    }
    public function setId(?int $id): void
    {
        $this->id = $id;
    }
    public function setName(string $name): void
    {
        $this->name = $name;
    }
    public function setNameFromSlug(string $slug): string
    {
        return parent::setNameFromSlug($slug);
    }
    public function resetName(): void
    {
        parent::resetName();
    }
}