canConvertFrom() 공개 메소드

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.
리턴 boolean TRUE if this TypeConverter can convert from $source to $targetType, FALSE otherwise.
 /**
  * @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'));
 }
 /**
  * @test
  */
 public function canConvertFromShouldReturnTrue()
 {
     $this->assertTrue($this->converter->canConvertFrom('myString', 'string'));
 }
 /**
  * @test
  */
 public function canConvertFromShouldReturnTrueForADateTimeValue()
 {
     $this->assertTrue($this->converter->canConvertFrom(new \DateTime(), 'integer'));
 }
 /**
  * @test
  */
 public function canConvertFromShouldReturnTrue()
 {
     $this->assertTrue($this->converter->canConvertFrom('de', I18n\Locale::class));
 }
 /**
  * @test
  */
 public function canConvertFromShouldReturnTrueForANullValue()
 {
     $this->assertTrue($this->converter->canConvertFrom(null, 'integer'));
 }