Classes/Pattern/Presentation/Component/ComponentFactory.php
/**
     * @param \ReflectionClass<object> $modelReflection
     * @param PrototypeInterface $prototype
     * @return Component
     */
@param \ReflectionClass $modelReflection
@param PrototypeInterface $prototype
@return Component
@param \ ReflectionClass $modelReflection @param PrototypeInterface $prototype @return Component
public function fromExisitingComponent(\ReflectionClass $modelReflection, PrototypeInterface $prototype): Component
    {
        $model = $this->modelFactory->fromExistingModel($modelReflection);
        $distributionPackage = $this->distributionPackageResolver->resolve($prototype->getName()->getPackageKey());
        $presentation = Presentation::fromDistributionPackage($distributionPackage);
        $name = StringUtil::truncateStart(StringUtil::dropHead(':', $prototype->getName()->asString()), 'Component.');
        $signature = $this->signatureFactory->forDistributionPackage($distributionPackage);
        $title = $prototype->getMeta()['styleguide']['title'] ?? 'Unknown';
        $props = [];
        foreach ($model->getProperties() as $property) {
            $props[] = new Prop(
                $property->getName(),
                $this->propTypeFactory->fromExistingStyleguideExample(
                    $prototype->getMeta()['styleguide']['props'][$property->getName()] ?? null
                )
            );
        }
        return new Component($presentation, $name, $model, $signature, $title, $props);
    }
public function fromExisitingComponent ( \ ReflectionClass $ modelReflection , PrototypeInterface $ prototype ) : Component { $ model = $ this -> modelFactory -> fromExistingModel ( $ modelReflection ) ; $ distributionPackage = $ this -> distributionPackageResolver -> resolve ( $ prototype -> getName ( ) -> getPackageKey ( ) ) ; $ presentation = Presentation :: fromDistributionPackage ( $ distributionPackage ) ; $ name = StringUtil :: truncateStart ( StringUtil :: dropHead ( ':' , $ prototype -> getName ( ) -> asString ( ) ) , 'Component.' ) ; $ signature = $ this -> signatureFactory -> forDistributionPackage ( $ distributionPackage ) ; $ title = $ prototype -> getMeta ( ) [ 'styleguide' ] [ 'title' ] ?? 'Unknown' ; $ props = [ ] ; foreach ( $ model -> getProperties ( ) as $ property ) { $ props [ ] = new Prop ( $ property -> getName ( ) , $ this -> propTypeFactory -> fromExistingStyleguideExample ( $ prototype -> getMeta ( ) [ 'styleguide' ] [ 'props' ] [ $ property -> getName ( ) ] ?? null ) ) ; } return new Component ( $ presentation , $ name , $ model , $ signature , $ title , $ props ) ; }
@param \ReflectionClass<object> $modelReflection
 @param PrototypeInterface $prototype
 @return Component
@param \ ReflectionClass<object > $modelReflection @param PrototypeInterface $prototype @return Component