src/ClientBase.php
protected function parseOptionCodes(array $options)
    {
        $valid_options = [];
        foreach ($options['option_codes'] as $optionCode) {
            if (!array_key_exists(strtoupper($optionCode), self::getOptionCodes())) {
                $message = sprintf(
                    'Unsupported option code: "%s". Supported options are %s',
                    $optionCode,
                    implode(', ', array_keys(self::getOptionCodes()))
                );
                throw new \InvalidArgumentException($message);
            }
            // @todo Perhaps we should check for conflicts here, might be overkill.
            // From Canada Post docs:
            // There are some options that can be applied to a shipment that
            // conflict with the presence of another option. You can use the
            // "Get Option" call in advance to check the contents of the
            // <conflicting-options> group from a Get Option call for options
            // selected by end users or options available for a given service.
            $valid_options[] = [
                'option-code' => $optionCode,
            ];
        }

        return $valid_options;
    }
protected function parseOptionCodes(array $options)
    {
        $valid_options = [];
        foreach ($options['option_codes'] as $optionCode) {
            if (!array_key_exists(strtoupper($optionCode), self::getOptionCodes())) {
                $message = sprintf(
                    'Unsupported option code: "%s". Supported options are %s',
                    $optionCode,
                    implode(', ', array_keys(self::getOptionCodes()))
                );
                throw new \InvalidArgumentException($message);
            }
            // @todo Perhaps we should check for conflicts here, might be overkill.
            // From Canada Post docs:
            // There are some options that can be applied to a shipment that
            // conflict with the presence of another option. You can use the
            // "Get Option" call in advance to check the contents of the
            // <conflicting-options> group from a Get Option call for options
            // selected by end users or options available for a given service.
            $valid_options[] = [
                'option-code' => $optionCode,
            ];
        }

        return $valid_options;
    }
protected function parseOptionCodes ( array $ options ) { $ valid_options = [ ] ; foreach ( $ options [ 'option_codes' ] as $ optionCode ) { if ( ! array_key_exists ( strtoupper ( $ optionCode ) , self :: getOptionCodes ( ) ) ) { $ message = sprintf ( 'Unsupported option code: "%s". Supported options are %s' , $ optionCode , implode ( ', ' , array_keys ( self :: getOptionCodes ( ) ) ) ) ; throw new \ InvalidArgumentException ( $ message ) ; } // @todo Perhaps we should check for conflicts here, might be overkill. // From Canada Post docs: // There are some options that can be applied to a shipment that // conflict with the presence of another option. You can use the // "Get Option" call in advance to check the contents of the // <conflicting-options> group from a Get Option call for options // selected by end users or options available for a given service. $ valid_options [ ] = [ 'option-code' => $ optionCode , ] ; } return $ valid_options ; }
Helper function to extract the option codes.

@param array $options
The options array.

@return array
The list of options with the option-code.
Helper function to extract the option codes .