Classes/Pattern/Presentation/Component/ComponentFactory.php
/**
     * @param Query $query
     * @param PropTypeFactory $propTypeFactory
     * @return Component
     */
@param Query $query
@param PropTypeFactory $propTypeFactory
@return Component
@param Query $query @param PropTypeFactory $propTypeFactory @return Component
public function fromQuery(Query $query, PropTypeFactory $propTypeFactory): Component
    {
        $model = $this->modelFactory->fromQuery($query);
        $distributionPackage = $this->distributionPackageResolver->resolve($query->optional('package')->string());
        $presentation = Presentation::fromDistributionPackage($distributionPackage);
        $name = str_replace('\\', '.', $query->required('name')->type()->asString());
        $signature = $this->signatureFactory->forDistributionPackage($distributionPackage);
        $title = $query->optional('title')->string() ?? StringUtil::tail('.', $name);
        $props = [];
        foreach ($query->optional('props')->dictionary() as $propName => $type) {
            $type = $type->type()->substitute([
                'foreignNamespace' => '\\{package}\\Presentation\\{namespace}',
                'domesticNamespace' => '\\' . $presentation->getPhpNamespace()->asString() . '\\{namespace}',
                'localNamespace' => StringUtil::tail('\\', $model->getPhpClassNameForValueObject()->asFullyQualifiedNameString()) . '\\{className}'
            ]);
            $props[] = new Prop($propName, $propTypeFactory->fromString($type->asAtomicString()));
        }
        return new Component($presentation, $name, $model, $signature, $title, $props);
    }
public function fromQuery ( Query $ query , PropTypeFactory $ propTypeFactory ) : Component { $ model = $ this -> modelFactory -> fromQuery ( $ query ) ; $ distributionPackage = $ this -> distributionPackageResolver -> resolve ( $ query -> optional ( 'package' ) -> string ( ) ) ; $ presentation = Presentation :: fromDistributionPackage ( $ distributionPackage ) ; $ name = str_replace ( '\\' , '.' , $ query -> required ( 'name' ) -> type ( ) -> asString ( ) ) ; $ signature = $ this -> signatureFactory -> forDistributionPackage ( $ distributionPackage ) ; $ title = $ query -> optional ( 'title' ) -> string ( ) ?? StringUtil :: tail ( '.' , $ name ) ; $ props = [ ] ; foreach ( $ query -> optional ( 'props' ) -> dictionary ( ) as $ propName => $ type ) { $ type = $ type -> type ( ) -> substitute ( [ 'foreignNamespace' => '\\{package}\\Presentation\\{namespace}' , 'domesticNamespace' => '\\' . $ presentation -> getPhpNamespace ( ) -> asString ( ) . '\\{namespace}' , 'localNamespace' => StringUtil :: tail ( '\\' , $ model -> getPhpClassNameForValueObject ( ) -> asFullyQualifiedNameString ( ) ) . '\\{className}' ] ) ; $ props [ ] = new Prop ( $ propName , $ propTypeFactory -> fromString ( $ type -> asAtomicString ( ) ) ) ; } return new Component ( $ presentation , $ name , $ model , $ signature , $ title , $ props ) ; }
@param Query $query
 @param PropTypeFactory $propTypeFactory
 @return Component
@param Query $query @param PropTypeFactory $propTypeFactory @return Component