public function getAlgorithm()
    {
        if (null === $this->algorithm) {
            $this->reader->seek(-4, SEEK_END);

            if ('GBMB' !== $this->reader->read(4)) {
                throw SignatureException::createUsingFormat(
                    'The archive "%s" is not signed.',
                    $this->reader->getFile()
                );
            }

            $this->reader->seek(-8, SEEK_END);

            $flag = unpack('V', $this->reader->read(4));
            $flag = (int) $flag[1];

            foreach ($this->algorithms as $algorithm) {
                if ($flag === $algorithm->getFlag()) {
                    $this->algorithm = $algorithm;
                }
            }

            if (null === $this->algorithm) {
                throw SignatureException::createUsingFormat(
                    'The algorithm for the archive "%s" is not supported.',
                    $this->reader->getFile()
                );
            }
        }

        return $this->algorithm;
    }
public function getAlgorithm()
    {
        if (null === $this->algorithm) {
            $this->reader->seek(-4, SEEK_END);

            if ('GBMB' !== $this->reader->read(4)) {
                throw SignatureException::createUsingFormat(
                    'The archive "%s" is not signed.',
                    $this->reader->getFile()
                );
            }

            $this->reader->seek(-8, SEEK_END);

            $flag = unpack('V', $this->reader->read(4));
            $flag = (int) $flag[1];

            foreach ($this->algorithms as $algorithm) {
                if ($flag === $algorithm->getFlag()) {
                    $this->algorithm = $algorithm;
                }
            }

            if (null === $this->algorithm) {
                throw SignatureException::createUsingFormat(
                    'The algorithm for the archive "%s" is not supported.',
                    $this->reader->getFile()
                );
            }
        }

        return $this->algorithm;
    }
public function getAlgorithm ( ) { if ( null === $ this -> algorithm ) { $ this -> reader -> seek ( - 4 , SEEK_END ) ; if ( 'GBMB' !== $ this -> reader -> read ( 4 ) ) { throw SignatureException :: createUsingFormat ( 'The archive "%s" is not signed.' , $ this -> reader -> getFile ( ) ) ; } $ this -> reader -> seek ( - 8 , SEEK_END ) ; $ flag = unpack ( 'V' , $ this -> reader -> read ( 4 ) ) ; $ flag = ( int ) $ flag [ 1 ] ; foreach ( $ this -> algorithms as $ algorithm ) { if ( $ flag === $ algorithm -> getFlag ( ) ) { $ this -> algorithm = $ algorithm ; } } if ( null === $ this -> algorithm ) { throw SignatureException :: createUsingFormat ( 'The algorithm for the archive "%s" is not supported.' , $ this -> reader -> getFile ( ) ) ; } } return $ this -> algorithm ; }
Returns the algorithm used for the archive file.

This method will detect the algorithm used by the archive file and
return one of the registered algorithm classes that will be used to
extract and verify the signature.

// instance of Phine\Phar\Signature\Algorithm\SHA1
$algorithm = $signature->getAlgorithm();

> Note that only registered algorithms can be recognized by the
> instance. If an unrecognized algorithm is used by the archive
> file, an exception will be thrown.

@return AlgorithmInterface The algorithm.

@throws Exception
@throws SignatureException If the algorithm could not be found.

@api
Returns the algorithm used for the archive file .