protected function convertBinaryToUri(Component\VCard $output, Property\Binary $newProperty, array &$parameters)
    {
        $value = $newProperty->getValue();
        $newProperty = $output->createProperty(
            $newProperty->name,
            null, // no value
            [], // no parameters yet
            'URI' // Forcing the BINARY type
        );

        $mimeType = 'application/octet-stream';

        // See if we can find a better mimetype.
        if (isset($parameters['TYPE'])) {
            $newTypes = [];
            foreach ($parameters['TYPE']->getParts() as $typePart) {
                if (in_array(
                    strtoupper($typePart),
                    ['JPEG', 'PNG', 'GIF']
                )) {
                    $mimeType = 'image/'.strtolower($typePart);
                } else {
                    $newTypes[] = $typePart;
                }
            }

            // If there were any parameters we're not converting to a
            // mime-type, we need to keep them.
            if ($newTypes) {
                $parameters['TYPE']->setParts($newTypes);
            } else {
                unset($parameters['TYPE']);
            }
        }

        $newProperty->setValue('data:'.$mimeType.';base64,'.base64_encode($value));

        return $newProperty;
    }
protected function convertBinaryToUri(Component\VCard $output, Property\Binary $newProperty, array &$parameters)
    {
        $value = $newProperty->getValue();
        $newProperty = $output->createProperty(
            $newProperty->name,
            null, // no value
            [], // no parameters yet
            'URI' // Forcing the BINARY type
        );

        $mimeType = 'application/octet-stream';

        // See if we can find a better mimetype.
        if (isset($parameters['TYPE'])) {
            $newTypes = [];
            foreach ($parameters['TYPE']->getParts() as $typePart) {
                if (in_array(
                    strtoupper($typePart),
                    ['JPEG', 'PNG', 'GIF']
                )) {
                    $mimeType = 'image/'.strtolower($typePart);
                } else {
                    $newTypes[] = $typePart;
                }
            }

            // If there were any parameters we're not converting to a
            // mime-type, we need to keep them.
            if ($newTypes) {
                $parameters['TYPE']->setParts($newTypes);
            } else {
                unset($parameters['TYPE']);
            }
        }

        $newProperty->setValue('data:'.$mimeType.';base64,'.base64_encode($value));

        return $newProperty;
    }
protected function convertBinaryToUri ( Component \ VCard $ output , Property \ Binary $ newProperty , array & $ parameters ) { $ value = $ newProperty -> getValue ( ) ; $ newProperty = $ output -> createProperty ( $ newProperty -> name , null , // no value [ ] , // no parameters yet 'URI' // Forcing the BINARY type ) ; $ mimeType = 'application/octet-stream' ; // See if we can find a better mimetype. if ( isset ( $ parameters [ 'TYPE' ] ) ) { $ newTypes = [ ] ; foreach ( $ parameters [ 'TYPE' ] -> getParts ( ) as $ typePart ) { if ( in_array ( strtoupper ( $ typePart ) , [ 'JPEG' , 'PNG' , 'GIF' ] ) ) { $ mimeType = 'image/' . strtolower ( $ typePart ) ; } else { $ newTypes [ ] = $ typePart ; } } // If there were any parameters we're not converting to a // mime-type, we need to keep them. if ( $ newTypes ) { $ parameters [ 'TYPE' ] -> setParts ( $ newTypes ) ; } else { unset ( $ parameters [ 'TYPE' ] ) ; } } $ newProperty -> setValue ( 'data:' . $ mimeType . ';base64,' . base64_encode ( $ value ) ) ; return $ newProperty ; }
Converts a BINARY property to a URI property.

vCard 4.0 no longer supports BINARY properties.

@param Component\VCard $output
@param Property\Uri    $property the input property
@param $parameters list of parameters that will eventually be added to
the new property

@return Property\Uri
Converts a BINARY property to a URI property .