protected function convertUriToBinary(Component\VCard $output, Property\Uri $newProperty)
    {
        $value = $newProperty->getValue();

        // Only converting data: uris
        if ('data:' !== substr($value, 0, 5)) {
            return $newProperty;
        }

        $newProperty = $output->createProperty(
            $newProperty->name,
            null, // no value
            [], // no parameters yet
            'BINARY'
        );

        $mimeType = substr($value, 5, strpos($value, ',') - 5);
        if (strpos($mimeType, ';')) {
            $mimeType = substr($mimeType, 0, strpos($mimeType, ';'));
            $newProperty->setValue(base64_decode(substr($value, strpos($value, ',') + 1)));
        } else {
            $newProperty->setValue(substr($value, strpos($value, ',') + 1));
        }
        unset($value);

        $newProperty['ENCODING'] = 'b';
        switch ($mimeType) {
            case 'image/jpeg':
                $newProperty['TYPE'] = 'JPEG';
                break;
            case 'image/png':
                $newProperty['TYPE'] = 'PNG';
                break;
            case 'image/gif':
                $newProperty['TYPE'] = 'GIF';
                break;
        }

        return $newProperty;
    }
protected function convertUriToBinary(Component\VCard $output, Property\Uri $newProperty)
    {
        $value = $newProperty->getValue();

        // Only converting data: uris
        if ('data:' !== substr($value, 0, 5)) {
            return $newProperty;
        }

        $newProperty = $output->createProperty(
            $newProperty->name,
            null, // no value
            [], // no parameters yet
            'BINARY'
        );

        $mimeType = substr($value, 5, strpos($value, ',') - 5);
        if (strpos($mimeType, ';')) {
            $mimeType = substr($mimeType, 0, strpos($mimeType, ';'));
            $newProperty->setValue(base64_decode(substr($value, strpos($value, ',') + 1)));
        } else {
            $newProperty->setValue(substr($value, strpos($value, ',') + 1));
        }
        unset($value);

        $newProperty['ENCODING'] = 'b';
        switch ($mimeType) {
            case 'image/jpeg':
                $newProperty['TYPE'] = 'JPEG';
                break;
            case 'image/png':
                $newProperty['TYPE'] = 'PNG';
                break;
            case 'image/gif':
                $newProperty['TYPE'] = 'GIF';
                break;
        }

        return $newProperty;
    }
protected function convertUriToBinary ( Component \ VCard $ output , Property \ Uri $ newProperty ) { $ value = $ newProperty -> getValue ( ) ; // Only converting data: uris if ( 'data:' !== substr ( $ value , 0 , 5 ) ) { return $ newProperty ; } $ newProperty = $ output -> createProperty ( $ newProperty -> name , null , // no value [ ] , // no parameters yet 'BINARY' ) ; $ mimeType = substr ( $ value , 5 , strpos ( $ value , ',' ) - 5 ) ; if ( strpos ( $ mimeType , ';' ) ) { $ mimeType = substr ( $ mimeType , 0 , strpos ( $ mimeType , ';' ) ) ; $ newProperty -> setValue ( base64_decode ( substr ( $ value , strpos ( $ value , ',' ) + 1 ) ) ) ; } else { $ newProperty -> setValue ( substr ( $ value , strpos ( $ value , ',' ) + 1 ) ) ; } unset ( $ value ) ; $ newProperty [ 'ENCODING' ] = 'b' ; switch ( $ mimeType ) { case 'image/jpeg' : $ newProperty [ 'TYPE' ] = 'JPEG' ; break ; case 'image/png' : $ newProperty [ 'TYPE' ] = 'PNG' ; break ; case 'image/gif' : $ newProperty [ 'TYPE' ] = 'GIF' ; break ; } return $ newProperty ; }
Converts a URI property to a BINARY property.

In vCard 4.0 attachments are encoded as data: uri. Even though these may
be valid in vCard 3.0 as well, we should convert those to BINARY if
possible, to improve compatibility.

@param Component\VCard $output
@param Property\Uri    $property the input property

@return Property\Binary|null
Converts a URI property to a BINARY property .