You are here

class Braintree_MultipleValueNode in Commerce Braintree 7

Hierarchy

Expanded class hierarchy of Braintree_MultipleValueNode

4 string references to 'Braintree_MultipleValueNode'
Braintree_SubscriptionSearchTest::testSearch_ids_isMultipleValueNode in braintree_php/tests/unit/SubscriptionSearchTest.php
Braintree_SubscriptionSearchTest::testSearch_inTrialPeriod_isMultipleValueNode in braintree_php/tests/unit/SubscriptionSearchTest.php
Braintree_SubscriptionSearchTest::testSearch_merchantAccountId_isMultipleValueNode in braintree_php/tests/unit/SubscriptionSearchTest.php
Braintree_SubscriptionSearchTest::testSearch_status_isMultipleValueNode in braintree_php/tests/unit/SubscriptionSearchTest.php

File

braintree_php/lib/Braintree/MultipleValueNode.php, line 3

View source
class Braintree_MultipleValueNode {
  function __construct($name, $allowedValues = array()) {
    $this->name = $name;
    $this->items = array();
    $this->allowedValues = $allowedValues;
  }
  function in($values) {
    $bad_values = array_diff($values, $this->allowedValues);
    if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
      $message = 'Invalid argument(s) for ' . $this->name . ':';
      foreach ($bad_values as $bad_value) {
        $message .= ' ' . $bad_value;
      }
      throw new InvalidArgumentException($message);
    }
    $this->items = $values;
    return $this;
  }
  function is($value) {
    return $this
      ->in(array(
      $value,
    ));
  }
  function toParam() {
    return $this->items;
  }

}

Members