public static function convert(Anchor $protobufAnchor)
    {
        $anchorMap = null;
        $ASN1 = new ASN1();
        $X509 = new X509();
        $anchorSubType = $protobufAnchor->getSubType();
        $yotiSignedTimeStamp = self::convertToYotiSignedTimestamp($protobufAnchor);
        $X509CertsList = self::convertCertsListToX509($X509, $protobufAnchor->getOriginServerCerts());
        $anchorTypesMap = self::getAnchorTypesMap();

        foreach ($X509CertsList as $certX509Obj) {
            $certExtsArr = $certX509Obj->tbsCertificate->extensions;

            foreach ($anchorTypesMap as $oid => $anchorType) {
                foreach ($certExtsArr as $extObj) {
                    $extArr = (array) $extObj;
                    $oidFound = array_search($oid, $extArr, true);
                    if ($oidFound !== false && is_string($extArr['extnValue'])) {
                        $extEncodedValue = $extArr['extnValue'];

                        if ($decodedAnchorValue = self::decodeAnchorValue($ASN1, $X509, $extEncodedValue)) {
                            $yotiAnchor = self::createYotiAnchor(
                                $decodedAnchorValue,
                                $anchorType,
                                $anchorSubType,
                                $yotiSignedTimeStamp,
                                $X509CertsList
                            );
                            $anchorMap = [
                                'oid' => $oid,
                                'yoti_anchor' => $yotiAnchor
                            ];
                            // We are only looking for one YotiAnchor from protobufAnchor
                            return $anchorMap;
                        }
                    }
                }
            }
        }
        return $anchorMap;
    }
public static function convert(Anchor $protobufAnchor)
    {
        $anchorMap = null;
        $ASN1 = new ASN1();
        $X509 = new X509();
        $anchorSubType = $protobufAnchor->getSubType();
        $yotiSignedTimeStamp = self::convertToYotiSignedTimestamp($protobufAnchor);
        $X509CertsList = self::convertCertsListToX509($X509, $protobufAnchor->getOriginServerCerts());
        $anchorTypesMap = self::getAnchorTypesMap();

        foreach ($X509CertsList as $certX509Obj) {
            $certExtsArr = $certX509Obj->tbsCertificate->extensions;

            foreach ($anchorTypesMap as $oid => $anchorType) {
                foreach ($certExtsArr as $extObj) {
                    $extArr = (array) $extObj;
                    $oidFound = array_search($oid, $extArr, true);
                    if ($oidFound !== false && is_string($extArr['extnValue'])) {
                        $extEncodedValue = $extArr['extnValue'];

                        if ($decodedAnchorValue = self::decodeAnchorValue($ASN1, $X509, $extEncodedValue)) {
                            $yotiAnchor = self::createYotiAnchor(
                                $decodedAnchorValue,
                                $anchorType,
                                $anchorSubType,
                                $yotiSignedTimeStamp,
                                $X509CertsList
                            );
                            $anchorMap = [
                                'oid' => $oid,
                                'yoti_anchor' => $yotiAnchor
                            ];
                            // We are only looking for one YotiAnchor from protobufAnchor
                            return $anchorMap;
                        }
                    }
                }
            }
        }
        return $anchorMap;
    }
public static function convert ( Anchor $ protobufAnchor ) { $ anchorMap = null ; $ ASN1 = new ASN1 ( ) ; $ X509 = new X509 ( ) ; $ anchorSubType = $ protobufAnchor -> getSubType ( ) ; $ yotiSignedTimeStamp = self :: convertToYotiSignedTimestamp ( $ protobufAnchor ) ; $ X509CertsList = self :: convertCertsListToX509 ( $ X509 , $ protobufAnchor -> getOriginServerCerts ( ) ) ; $ anchorTypesMap = self :: getAnchorTypesMap ( ) ; foreach ( $ X509CertsList as $ certX509Obj ) { $ certExtsArr = $ certX509Obj -> tbsCertificate -> extensions ; foreach ( $ anchorTypesMap as $ oid => $ anchorType ) { foreach ( $ certExtsArr as $ extObj ) { $ extArr = ( array ) $ extObj ; $ oidFound = array_search ( $ oid , $ extArr , true ) ; if ( $ oidFound !== false && is_string ( $ extArr [ 'extnValue' ] ) ) { $ extEncodedValue = $ extArr [ 'extnValue' ] ; if ( $ decodedAnchorValue = self :: decodeAnchorValue ( $ ASN1 , $ X509 , $ extEncodedValue ) ) { $ yotiAnchor = self :: createYotiAnchor ( $ decodedAnchorValue , $ anchorType , $ anchorSubType , $ yotiSignedTimeStamp , $ X509CertsList ) ; $ anchorMap = [ 'oid' => $ oid , 'yoti_anchor' => $ yotiAnchor ] ; // We are only looking for one YotiAnchor from protobufAnchor return $ anchorMap ; } } } } } return $ anchorMap ; }
Convert Protobuf Anchor to a map of oid -> Yoti Anchor

@param Anchor $anchor

@return array|null
Convert Protobuf Anchor to a map of oid - > Yoti Anchor