Milon\Barcode\PDF417::getInputSequences PHP Метод

getInputSequences() защищенный Метод

Create array of sequences from input
protected getInputSequences ( $code ) : bidimensional
$code (string) code
Результат bidimensional array containing characters and classification
    protected function getInputSequences($code)
    {
        $sequence_array = array();
        // array to be returned
        $numseq = array();
        // get numeric sequences
        preg_match_all('/([0-9]{13,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
        $numseq[1][] = array('', strlen($code));
        $offset = 0;
        foreach ($numseq[1] as $seq) {
            $seqlen = strlen($seq[0]);
            if ($seq[1] > 0) {
                // extract text sequence before the number sequence
                $prevseq = substr($code, $offset, $seq[1] - $offset);
                $textseq = array();
                // get text sequences
                preg_match_all('/([\\x09\\x0a\\x0d\\x20-\\x7e]{5,})/', $prevseq, $textseq, PREG_OFFSET_CAPTURE);
                $textseq[1][] = array('', strlen($prevseq));
                $txtoffset = 0;
                foreach ($textseq[1] as $txtseq) {
                    $txtseqlen = strlen($txtseq[0]);
                    if ($txtseq[1] > 0) {
                        // extract byte sequence before the text sequence
                        $prevtxtseq = substr($prevseq, $txtoffset, $txtseq[1] - $txtoffset);
                        if (strlen($prevtxtseq) > 0) {
                            // add BYTE sequence
                            if (strlen($prevtxtseq) == 1 and (count($sequence_array) > 0 and $sequence_array[count($sequence_array) - 1][0] == 900)) {
                                $sequence_array[] = array(913, $prevtxtseq);
                            } elseif (strlen($prevtxtseq) % 6 == 0) {
                                $sequence_array[] = array(924, $prevtxtseq);
                            } else {
                                $sequence_array[] = array(901, $prevtxtseq);
                            }
                        }
                    }
                    if ($txtseqlen > 0) {
                        // add numeric sequence
                        $sequence_array[] = array(900, $txtseq[0]);
                    }
                    $txtoffset = $txtseq[1] + $txtseqlen;
                }
            }
            if ($seqlen > 0) {
                // add numeric sequence
                $sequence_array[] = array(902, $seq[0]);
            }
            $offset = $seq[1] + $seqlen;
        }
        return $sequence_array;
    }