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 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 62
UserDataMutable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 16
1892
0.00% covered (danger)
0.00%
0 / 62
 __construct
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 15
 fromArray
0.00% covered (danger)
0.00%
0 / 1
72
0.00% covered (danger)
0.00%
0 / 10
 fromIterable
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 11
 getId
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getUsername
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getPassword
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getRoles
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getFullName
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getEmail
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
56
0.00% covered (danger)
0.00%
0 / 8
 setId
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 2
 setUsername
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setPassword
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setRoles
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setFullName
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setEmail
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\User\UserData;
use InvalidArgumentException;
use Smalldb\CodeCooker\Annotation\GeneratedClass;
use Smalldb\StateMachine\Test\Example\User\UserProperties as Source_UserProperties;
/**
 * @GeneratedClass
 * @see \Smalldb\StateMachine\Test\Example\User\UserProperties
 */
class UserDataMutable extends Source_UserProperties implements UserData
{
    public function __construct(?UserData $source = null)
    {
        if ($source !== null) {
            if ($source instanceof Source_UserProperties) {
                $this->id = $source->id;
                $this->username = $source->username;
                $this->password = $source->password;
                $this->roles = $source->roles;
                $this->fullName = $source->fullName;
                $this->email = $source->email;
            } else {
                $this->id = $source->getId();
                $this->username = $source->getUsername();
                $this->password = $source->getPassword();
                $this->roles = $source->getRoles();
                $this->fullName = $source->getFullName();
                $this->email = $source->getEmail();
            }
        }
    }
    public static function fromArray(?array $source, ?UserData $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->username = (string) $source['username'];
        $t->password = (string) $source['password'];
        $t->roles = is_string($source['roles']) ? json_decode($source['roles'], TRUE) : (array) $source['roles'];
        $t->fullName = (string) $source['fullName'];
        $t->email = (string) $source['email'];
        return $t;
    }
    public static function fromIterable(?UserData $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 'username': $t->username = $value; break;
                case 'password': $t->password = $value; break;
                case 'roles': $t->roles = $value; break;
                case 'fullName': $t->fullName = $value; break;
                case 'email': $t->email = $value; break;
                default: throw new InvalidArgumentException('Unknown property: "' . $prop . '" not in ' . __CLASS__);
            }
        }
        return $t;
    }
    public function getId(): ?int
    {
        return $this->id;
    }
    public function getUsername(): string
    {
        return $this->username;
    }
    public function getPassword(): string
    {
        return $this->password;
    }
    public function getRoles(): array
    {
        return $this->roles;
    }
    public function getFullName(): string
    {
        return $this->fullName;
    }
    public function getEmail(): string
    {
        return $this->email;
    }
    public static function get(UserData $source, string $propertyName)
    {
        switch ($propertyName) {
            case 'id': return $source->getId();
            case 'username': return $source->getUsername();
            case 'password': return $source->getPassword();
            case 'roles': return $source->getRoles();
            case 'fullName': return $source->getFullName();
            case 'email': return $source->getEmail();
            default: throw new \InvalidArgumentException("Unknown property: " . $propertyName);
        }
    }
    public function setId(?int $id): void
    {
        $this->id = $id;
    }
    public function setUsername(string $username): void
    {
        $this->username = $username;
    }
    public function setPassword(string $password): void
    {
        $this->password = $password;
    }
    public function setRoles(array $roles): void
    {
        $this->roles = $roles;
    }
    public function setFullName(string $fullName): void
    {
        $this->fullName = $fullName;
    }
    public function setEmail(string $email): void
    {
        $this->email = $email;
    }
}