public function setTrackingCode($barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber) {
        $barcodeIdentifier = (string)(int)$barcodeIdentifier;
        $serviceTypeIdentifier = (int)$serviceTypeIdentifier;
        $mailerIdentifier = (int)$mailerIdentifier;
        $serialNumber = (string)(int)$serialNumber;

        $barcodeIdentifier = str_pad($barcodeIdentifier, 2, '0', STR_PAD_LEFT);

        if (strlen($barcodeIdentifier) !== 2) {
            throw new CINArgumentException('Barcode Identifier must contain 2 digits.', 'barcodeIdentifier');
        }

        $barcodeIdentifierSecondNumber = $barcodeIdentifier[1];
        if ($barcodeIdentifierSecondNumber !== '0' && $barcodeIdentifierSecondNumber !== '1' && $barcodeIdentifierSecondNumber !== '2' && $barcodeIdentifierSecondNumber !== '3' && $barcodeIdentifierSecondNumber !== '4') {
            throw new CINArgumentException('Barcode Identifier second digit must be a number between 0 and 4.', 'barcodeIdentifier');
        }

        if ($serviceTypeIdentifier < 0 || $serviceTypeIdentifier > 999) {
            throw new CINArgumentException('Service Type Identifier must be between 0 and 999.', 'serviceTypeIdentifier');
        }

        $mailerIdentifierLength = 6;
        if ($mailerIdentifier > 899999) {
            $mailerIdentifierLength = 9;
        }

        if ($mailerIdentifierLength === 9 && strlen($serialNumber) > 6) {
            throw new CINArgumentException('If the Serial Number has more than 6 digits, the Mailer Identifier must be lower than 900000.', 'mailerIdentifier');
        }

        if ($mailerIdentifierLength === 9) {
            if ($mailerIdentifierLength < 0 || $mailerIdentifier > 999999999) {
                throw new CINArgumentException('Mailer Identifier must be between 0 and 999999999.', 'mailerIdentifier');
            }
        }

        $this->barcodeIdentifier = $barcodeIdentifier;
        $this->serviceTypeIdentifier = str_pad($serviceTypeIdentifier, 3, '0', STR_PAD_LEFT);
        $this->mailerIdentifier = str_pad($mailerIdentifier, $mailerIdentifierLength, '0', STR_PAD_LEFT);
        $this->serialNumber = str_pad((int)$serialNumber, $mailerIdentifierLength === 6 ? 9 : 6, '0', STR_PAD_LEFT);
    }
public function setTrackingCode($barcodeIdentifier, $serviceTypeIdentifier, $mailerIdentifier, $serialNumber) {
        $barcodeIdentifier = (string)(int)$barcodeIdentifier;
        $serviceTypeIdentifier = (int)$serviceTypeIdentifier;
        $mailerIdentifier = (int)$mailerIdentifier;
        $serialNumber = (string)(int)$serialNumber;

        $barcodeIdentifier = str_pad($barcodeIdentifier, 2, '0', STR_PAD_LEFT);

        if (strlen($barcodeIdentifier) !== 2) {
            throw new CINArgumentException('Barcode Identifier must contain 2 digits.', 'barcodeIdentifier');
        }

        $barcodeIdentifierSecondNumber = $barcodeIdentifier[1];
        if ($barcodeIdentifierSecondNumber !== '0' && $barcodeIdentifierSecondNumber !== '1' && $barcodeIdentifierSecondNumber !== '2' && $barcodeIdentifierSecondNumber !== '3' && $barcodeIdentifierSecondNumber !== '4') {
            throw new CINArgumentException('Barcode Identifier second digit must be a number between 0 and 4.', 'barcodeIdentifier');
        }

        if ($serviceTypeIdentifier < 0 || $serviceTypeIdentifier > 999) {
            throw new CINArgumentException('Service Type Identifier must be between 0 and 999.', 'serviceTypeIdentifier');
        }

        $mailerIdentifierLength = 6;
        if ($mailerIdentifier > 899999) {
            $mailerIdentifierLength = 9;
        }

        if ($mailerIdentifierLength === 9 && strlen($serialNumber) > 6) {
            throw new CINArgumentException('If the Serial Number has more than 6 digits, the Mailer Identifier must be lower than 900000.', 'mailerIdentifier');
        }

        if ($mailerIdentifierLength === 9) {
            if ($mailerIdentifierLength < 0 || $mailerIdentifier > 999999999) {
                throw new CINArgumentException('Mailer Identifier must be between 0 and 999999999.', 'mailerIdentifier');
            }
        }

        $this->barcodeIdentifier = $barcodeIdentifier;
        $this->serviceTypeIdentifier = str_pad($serviceTypeIdentifier, 3, '0', STR_PAD_LEFT);
        $this->mailerIdentifier = str_pad($mailerIdentifier, $mailerIdentifierLength, '0', STR_PAD_LEFT);
        $this->serialNumber = str_pad((int)$serialNumber, $mailerIdentifierLength === 6 ? 9 : 6, '0', STR_PAD_LEFT);
    }
public function setTrackingCode ( $ barcodeIdentifier , $ serviceTypeIdentifier , $ mailerIdentifier , $ serialNumber ) { $ barcodeIdentifier = ( string ) ( int ) $ barcodeIdentifier ; $ serviceTypeIdentifier = ( int ) $ serviceTypeIdentifier ; $ mailerIdentifier = ( int ) $ mailerIdentifier ; $ serialNumber = ( string ) ( int ) $ serialNumber ; $ barcodeIdentifier = str_pad ( $ barcodeIdentifier , 2 , '0' , STR_PAD_LEFT ) ; if ( strlen ( $ barcodeIdentifier ) !== 2 ) { throw new CINArgumentException ( 'Barcode Identifier must contain 2 digits.' , 'barcodeIdentifier' ) ; } $ barcodeIdentifierSecondNumber = $ barcodeIdentifier [ 1 ] ; if ( $ barcodeIdentifierSecondNumber !== '0' && $ barcodeIdentifierSecondNumber !== '1' && $ barcodeIdentifierSecondNumber !== '2' && $ barcodeIdentifierSecondNumber !== '3' && $ barcodeIdentifierSecondNumber !== '4' ) { throw new CINArgumentException ( 'Barcode Identifier second digit must be a number between 0 and 4.' , 'barcodeIdentifier' ) ; } if ( $ serviceTypeIdentifier < 0 || $ serviceTypeIdentifier > 999 ) { throw new CINArgumentException ( 'Service Type Identifier must be between 0 and 999.' , 'serviceTypeIdentifier' ) ; } $ mailerIdentifierLength = 6 ; if ( $ mailerIdentifier > 899999 ) { $ mailerIdentifierLength = 9 ; } if ( $ mailerIdentifierLength === 9 && strlen ( $ serialNumber ) > 6 ) { throw new CINArgumentException ( 'If the Serial Number has more than 6 digits, the Mailer Identifier must be lower than 900000.' , 'mailerIdentifier' ) ; } if ( $ mailerIdentifierLength === 9 ) { if ( $ mailerIdentifierLength < 0 || $ mailerIdentifier > 999999999 ) { throw new CINArgumentException ( 'Mailer Identifier must be between 0 and 999999999.' , 'mailerIdentifier' ) ; } } $ this -> barcodeIdentifier = $ barcodeIdentifier ; $ this -> serviceTypeIdentifier = str_pad ( $ serviceTypeIdentifier , 3 , '0' , STR_PAD_LEFT ) ; $ this -> mailerIdentifier = str_pad ( $ mailerIdentifier , $ mailerIdentifierLength , '0' , STR_PAD_LEFT ) ; $ this -> serialNumber = str_pad ( ( int ) $ serialNumber , $ mailerIdentifierLength === 6 ? 9 : 6 , '0' , STR_PAD_LEFT ) ; }
Sets the tracking code.

@param int $barcodeIdentifier 2-digit number. 2nd digit must be 0-4
@param int $serviceTypeIdentifier 3 digits
@param int $mailerIdentifier 6 or 9 digits
@param int $serialNumber 9 (if mailerId is 6) or 6 digits (if mailerId is 9)
Sets the tracking code .