public function createSigner(string $algorithm, $publicKey, $privateKey = null) : ISigner
    {
        if (!is_string($publicKey) && !is_resource($publicKey)) {
            throw new InvalidArgumentException('Public key must either be a string or a resource');
        }

        if ($this->algorithmIsSymmetric($algorithm)) {
            return new HmacSigner($algorithm, $publicKey);
        } else {
            if (!is_string($privateKey) && !is_resource($privateKey)) {
                throw new InvalidArgumentException('Must specify private key for asymmetric algorithms');
            }

            return new RsaSsaPkcsSigner($algorithm, $publicKey, $privateKey);
        }
    }
public function createSigner(string $algorithm, $publicKey, $privateKey = null) : ISigner
    {
        if (!is_string($publicKey) && !is_resource($publicKey)) {
            throw new InvalidArgumentException('Public key must either be a string or a resource');
        }

        if ($this->algorithmIsSymmetric($algorithm)) {
            return new HmacSigner($algorithm, $publicKey);
        } else {
            if (!is_string($privateKey) && !is_resource($privateKey)) {
                throw new InvalidArgumentException('Must specify private key for asymmetric algorithms');
            }

            return new RsaSsaPkcsSigner($algorithm, $publicKey, $privateKey);
        }
    }
public function createSigner ( string $ algorithm , $ publicKey , $ privateKey = null ) : ISigner { if ( ! is_string ( $ publicKey ) && ! is_resource ( $ publicKey ) ) { throw new InvalidArgumentException ( 'Public key must either be a string or a resource' ) ; } if ( $ this -> algorithmIsSymmetric ( $ algorithm ) ) { return new HmacSigner ( $ algorithm , $ publicKey ) ; } else { if ( ! is_string ( $ privateKey ) && ! is_resource ( $ privateKey ) ) { throw new InvalidArgumentException ( 'Must specify private key for asymmetric algorithms' ) ; } return new RsaSsaPkcsSigner ( $ algorithm , $ publicKey , $ privateKey ) ; } }
Creates a signer with the input algorithm

@param string $algorithm The algorithm to use (one of the Algorithms constants)
@param string|resource $publicKey The public key to sign data with
@param string|resource|null $privateKey The private key to sign data with (required for asymmetric algorithms)
@return ISigner The signer
@throws InvalidArgumentException Thrown if the keys are not in a valid format
Creates a signer with the input algorithm