Neos\Flow\Property\TypeConverterInterface::canConvertFrom PHP Method

canConvertFrom() public method

Here, the TypeConverter can do some additional runtime checks to see whether it can handle the given source data and the given target type.
public canConvertFrom ( mixed $source, string $targetType ) : boolean
$source mixed the source data
$targetType string the type to convert to.
return boolean TRUE if this TypeConverter can convert from $source to $targetType, FALSE otherwise.
    public function canConvertFrom($source, $targetType);

Usage Example

 /**
  * @test
  * @param boolean $isEntity
  * @param boolean $isValueObject
  * @param boolean $expected
  * @dataProvider dataProviderForCanConvert
  */
 public function canConvertFromReturnsTrueIfClassIsTaggedWithEntityOrValueObject($isEntity, $isValueObject, $expected)
 {
     if ($isEntity) {
         $this->mockReflectionService->expects($this->once())->method('isClassAnnotatedWith')->with('TheTargetType', Flow\Entity::class)->will($this->returnValue($isEntity));
     } else {
         $this->mockReflectionService->expects($this->at(0))->method('isClassAnnotatedWith')->with('TheTargetType', Flow\Entity::class)->will($this->returnValue($isEntity));
         $this->mockReflectionService->expects($this->at(1))->method('isClassAnnotatedWith')->with('TheTargetType', Flow\ValueObject::class)->will($this->returnValue($isValueObject));
     }
     $this->assertEquals($expected, $this->converter->canConvertFrom('myInputData', 'TheTargetType'));
 }
All Usage Examples Of Neos\Flow\Property\TypeConverterInterface::canConvertFrom