/** * @expectedException \Mcustiel\Conversion\Exception\ObjectIsNotConverterException * @expectedExceptionMessage Object of type stdClass does not implement Mcustiel\Conversion\Converter */ public function testShouldFailWhenImplementationIsNotConverter() { $builder = ConverterBuilder::get()->from(A::class)->to(B::class)->withImplementation(\stdClass::class); ConverterContainer::getInstance()->addConverter($builder); ConverterContainer::getInstance()->getConverter(A::class, B::class); }
/** * Registers a converter in the library for future use. * * @param ConverterBuilder $builder The converter builder that creates the converter to register */ public function registerConverter(ConverterBuilder $builder) { $this->container->addConverter($builder); }
private function addDefaultConverter() { $builder = ConverterBuilder::get()->from(A::class)->to(B::class)->withImplementation(AToBConverter::class); $this->conversionService->addConverter($builder); }