lib/TlsInfo.php
public static function fromMetaData(array $cryptoInfo, array $tlsContext): TlsInfo {
        return new self(
            $cryptoInfo["protocol"],
            $cryptoInfo["cipher_name"],
            $cryptoInfo["cipher_bits"],
            $cryptoInfo["cipher_version"],
            array_merge([$tlsContext["peer_certificate"]] ?: [], $tlsContext["peer_certificate_chain"] ?? [])
        );
    }
public static function fromMetaData(array $cryptoInfo, array $tlsContext): TlsInfo {
        return new self(
            $cryptoInfo["protocol"],
            $cryptoInfo["cipher_name"],
            $cryptoInfo["cipher_bits"],
            $cryptoInfo["cipher_version"],
            array_merge([$tlsContext["peer_certificate"]] ?: [], $tlsContext["peer_certificate_chain"] ?? [])
        );
    }
public static function fromMetaData ( array $ cryptoInfo , array $ tlsContext ) : TlsInfo { return new self ( $ cryptoInfo [ "protocol" ] , $ cryptoInfo [ "cipher_name" ] , $ cryptoInfo [ "cipher_bits" ] , $ cryptoInfo [ "cipher_version" ] , array_merge ( [ $ tlsContext [ "peer_certificate" ] ] ? : [ ] , $ tlsContext [ "peer_certificate_chain" ] ?? [ ] ) ) ; }
Constructs a new instance from PHP's internal info.

Always pass the info as obtained from PHP as this method might extract additional fields in the future.

@param array $cryptoInfo Crypto info obtained via `stream_get_meta_data($socket->getResource())["crypto"]`.
@param array $tlsContext Context obtained via `stream_context_get_options($socket->getResource())["ssl"])`.

@return TlsInfo
Constructs a new instance from PHP s internal info .