public function build() { $dispatcher = new ClassBasedTextGeneratorProxy(); $labelingVisitor = new TextGeneratorBasedLabelingVisitor($dispatcher); $dependencySetter = new SilentChainOfPropertySetters(new SimpleChainOfPropertySetters()); $dependencySetter->add(new SimplePropertySetter(new PickByClass(LabelingVisitorUser::class), new CallOnlyMethodAsSetter(LabelingVisitorUser::class), new UseDirectly($labelingVisitor))); foreach ($this->dependencyByDependentClass as $c => $d) { $dependencySetter->add(new SimplePropertySetter(new PickByClass($c), new CallOnlyMethodAsSetter($c), new UseDirectly($d))); } foreach ($this->genProtoByClassOfSupportedAgg as $supportedAggClass => $genProto) { $actualGenerator = clone $genProto; $dependencySetter->setPropertiesOf($actualGenerator); $dispatcher->registerActualGenerator($supportedAggClass, $actualGenerator); } return $labelingVisitor; }
/** * @return \lukaszmakuch\TextGenerator\TextGenerator */ protected function buildRequirementToTextConverter() { $c = new ClassBasedTextGeneratorProxy(); $c->registerActualGenerator(OlderThan::class, new OlderThanRenderer()); return $c; }