/** * Creates the PayPal message field object * @param string $name The fields name. * @param PayPalMessageComponent $value The fields value. * @throws LogicException */ public function __construct( $name , PayPalMessageComponent $value ) { parent::__construct( true ); if ( $value instanceof PayPalMessageField ) { throw new LogicException( 'The value of a PayPalMessageField cannot be an instance of PayPalMessageField.' ); } else { $this->name = $name; $this->value = $value; } }
/** * Creates a PayPalMessageComponent that represents a primitive value. * @param mixed $value * @throws InvalidArgumentException */ public function __construct( $value ) { parent::__construct( true ); $type = gettype( $value ); switch ( $type ){ case 'boolean' : case 'double' : case 'float' : case 'integer' : case 'string' : $this->value = $value; $this->type = $type; break; default : throw new InvalidArgumentException( 'Only primitive values are allowed, (' . $type . ') >' . $value . '< given.' ); } }
/** * For invocation by subclass constructors. */ public function __construct() { parent::__construct( false ); }