/**
  * @param int $source
  * @param string $targetModelClassname
  * @return AbstractModel
  * @throws PropertyMappingException
  */
 protected function mapToModel($source, $targetModelClassname)
 {
     $repositoryClassname = Nomenclature::modelClassnameToRepositoryClassname($targetModelClassname);
     if (!class_exists($repositoryClassname)) {
         throw new PropertyMappingException('Repository class ' . $repositoryClassname . ' for model ' . $targetModelClassname . ' does not exist.', 1409745296);
     }
     /** @var \AppZap\PHPFramework\Domain\Repository\AbstractDomainRepository $repository */
     $repository = $repositoryClassname::getInstance();
     return $repository->findById((int) $source);
 }
 /**
  * @param AbstractModel $object
  * @return array
  */
 public function objectToRecord(AbstractModel $object)
 {
     $record = [];
     foreach (get_class_methods($object) as $methodName) {
         $fieldname = Nomenclature::getterToFieldname($methodName);
         if (is_string($fieldname)) {
             $value = call_user_func([$object, $methodName]);
             $value = $this->scalarizeValue($value);
             $record[$fieldname] = $value;
         }
     }
     return $record;
 }
 /**
  * @return AbstractModel
  */
 protected function createEmptyModel()
 {
     $modelClassname = Nomenclature::repositoryClassnameToModelClassname(get_called_class());
     /** @var AbstractModel $model */
     $model = new $modelClassname();
     return $model;
 }
 /**
  * @test
  */
 public function repositoryclassnameToTablename()
 {
     $this->assertSame($this->names['table'], Nomenclature::repositoryClassnameToTablename($this->names['repository']));
 }