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

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

If conversion is possible.
public canConvertFrom ( string $source, string $targetType ) : boolean
$source string
$targetType string
Результат boolean
    public function canConvertFrom($source, $targetType)
    {
        if (!is_callable([$targetType, 'createFromFormat'])) {
            return false;
        }
        if (is_array($source)) {
            return true;
        }
        if (is_integer($source)) {
            return true;
        }
        return is_string($source);
    }

Usage Example

 /**
  * @test
  */
 public function canConvertFromReturnsTrueIfSourceTypeIsAnArray()
 {
     $this->assertTrue($this->converter->canConvertFrom([], 'DateTime'));
 }