Neos\Flow\Property\TypeConverter\TypedArrayConverter::canConvertFrom PHP Метод

canConvertFrom() публичный Метод

public canConvertFrom ( mixed $source, string $targetType ) : boolean
$source mixed
$targetType string
Результат boolean
    public function canConvertFrom($source, $targetType)
    {
        $targetTypeInformation = TypeHandling::parseType($targetType);
        if ($targetTypeInformation['type'] !== 'array') {
            return false;
        }
        return $targetTypeInformation['elementType'] !== null;
    }

Usage Example

 /**
  * @test
  * @dataProvider canConvertFromDataProvider
  */
 public function canConvertFromTests($targetType, $expectedResult)
 {
     $actualResult = $this->converter->canConvertFrom([], $targetType);
     if ($expectedResult === true) {
         $this->assertTrue($actualResult);
     } else {
         $this->assertFalse($actualResult);
     }
 }