public static function TryParse( $value, &$refReducer = null ) : bool
   {

      if ( \is_null( $value ) )
      {
         return false;
      }

      if ( $value instanceof \SimpleXMLElement )
      {

         return static::TryParseXmlElement( $value, $refReducer );

      }

      if ( \is_string( $value ) && ! empty( $value ) && $value[ 0 ] == '{' )
      {
         try
         {
            $array = \json_decode( $value, true );
            if ( ! \is_array( $array ) )
            {
               return false;
            }
            $value = $array;
         }
         catch ( \Throwable $ex ) { $ex = null; return false; }
      }

      if ( \is_array( $value ) )
      {

         if ( ! isset( $value[ 'type' ] ) )
         {
            return false;
         }

         if ( ! isset( $value[ 'width' ] ) )
         {
            $value[ 'width' ] = 0;
         }

         if ( ! isset( $value[ 'height' ] ) )
         {
            $value[ 'height' ] = 0;
         }

         if ( ! isset( $value[ 'landscape' ] ) )
         {
            $value[ 'landscape' ] = 0;
         }

         if ( ! isset( $value[ 'portrait' ] ) )
         {
            $value[ 'portrait' ] = 0;
         }

         if ( ! isset( $value[ 'gravity' ] ) )
         {
            $value[ 'gravity' ] = Gravity::MIDDLE_CENTER;
         }

         $refReducer = static::Create(
            \intval( $value[ 'type' ] ),
            \intval( $value[ 'width' ] ),
            \intval( $value[ 'height' ] ),
            \intval( $value[ 'gravity' ] ),
            \intval( $value[ 'portrait' ] ),
            \intval( $value[ 'landscape' ] )
         );

         return true;

      }

      return false;

   }
public static function TryParse( $value, &$refReducer = null ) : bool
   {

      if ( \is_null( $value ) )
      {
         return false;
      }

      if ( $value instanceof \SimpleXMLElement )
      {

         return static::TryParseXmlElement( $value, $refReducer );

      }

      if ( \is_string( $value ) && ! empty( $value ) && $value[ 0 ] == '{' )
      {
         try
         {
            $array = \json_decode( $value, true );
            if ( ! \is_array( $array ) )
            {
               return false;
            }
            $value = $array;
         }
         catch ( \Throwable $ex ) { $ex = null; return false; }
      }

      if ( \is_array( $value ) )
      {

         if ( ! isset( $value[ 'type' ] ) )
         {
            return false;
         }

         if ( ! isset( $value[ 'width' ] ) )
         {
            $value[ 'width' ] = 0;
         }

         if ( ! isset( $value[ 'height' ] ) )
         {
            $value[ 'height' ] = 0;
         }

         if ( ! isset( $value[ 'landscape' ] ) )
         {
            $value[ 'landscape' ] = 0;
         }

         if ( ! isset( $value[ 'portrait' ] ) )
         {
            $value[ 'portrait' ] = 0;
         }

         if ( ! isset( $value[ 'gravity' ] ) )
         {
            $value[ 'gravity' ] = Gravity::MIDDLE_CENTER;
         }

         $refReducer = static::Create(
            \intval( $value[ 'type' ] ),
            \intval( $value[ 'width' ] ),
            \intval( $value[ 'height' ] ),
            \intval( $value[ 'gravity' ] ),
            \intval( $value[ 'portrait' ] ),
            \intval( $value[ 'landscape' ] )
         );

         return true;

      }

      return false;

   }
public static function TryParse ( $ value , & $ refReducer = null ) : bool { if ( \ is_null ( $ value ) ) { return false ; } if ( $ value instanceof \ SimpleXMLElement ) { return static :: TryParseXmlElement ( $ value , $ refReducer ) ; } if ( \ is_string ( $ value ) && ! empty ( $ value ) && $ value [ 0 ] == '{' ) { try { $ array = \ json_decode ( $ value , true ) ; if ( ! \ is_array ( $ array ) ) { return false ; } $ value = $ array ; } catch ( \ Throwable $ ex ) { $ ex = null ; return false ; } } if ( \ is_array ( $ value ) ) { if ( ! isset ( $ value [ 'type' ] ) ) { return false ; } if ( ! isset ( $ value [ 'width' ] ) ) { $ value [ 'width' ] = 0 ; } if ( ! isset ( $ value [ 'height' ] ) ) { $ value [ 'height' ] = 0 ; } if ( ! isset ( $ value [ 'landscape' ] ) ) { $ value [ 'landscape' ] = 0 ; } if ( ! isset ( $ value [ 'portrait' ] ) ) { $ value [ 'portrait' ] = 0 ; } if ( ! isset ( $ value [ 'gravity' ] ) ) { $ value [ 'gravity' ] = Gravity :: MIDDLE_CENTER ; } $ refReducer = static :: Create ( \ intval ( $ value [ 'type' ] ) , \ intval ( $ value [ 'width' ] ) , \ intval ( $ value [ 'height' ] ) , \ intval ( $ value [ 'gravity' ] ) , \ intval ( $ value [ 'portrait' ] ) , \ intval ( $ value [ 'landscape' ] ) ) ; return true ; } return false ; }
Tries to parse the defined value to an ImageSizeReducer instance

@param \SimpleXMLElement|array|string         $value
@param \Beluga\Drawing\Image\ImageSizeReducer $refReducer Returns the resulting reducer instance
if the method return TRUE
@return bool
Tries to parse the defined value to an ImageSizeReducer instance