original_string: function addCartItem($name, $quantity, $totalAmount, $description = "") {
  
  		if (count($this->cart) >= 2) {
  			throw new Exception("This version of banks's API supports only up to 2 cart items in single payment, you can't add any more items.");
  		}
  
  		if (!is_numeric($quantity) or $quantity < 1) {
  			throw new Exception("Invalid quantity: $quantity. It must be numeric and >= 1");
  		}
  
  		$name = trim(Strings::shorten($name, 20, "", true, true));
  		$description = trim(Strings::shorten($description, 40, "", true, true));
  
  		$this->cart[] = array(
  			"name" => $name,
  			"quantity" => $quantity,
  			"amount" => intval(round($totalAmount)),
  			"description" => $description
  		);
  
  		return $this;
  	}
code: function addCartItem($name, $quantity, $totalAmount, $description = "") {
  
  		if (count($this->cart) >= 2) {
  			throw new Exception("This version of banks's API supports only up to 2 cart items in single payment, you can't add any more items.");
  		}
  
  		if (!is_numeric($quantity) or $quantity < 1) {
  			throw new Exception("Invalid quantity: $quantity. It must be numeric and >= 1");
  		}
  
  		$name = trim(Strings::shorten($name, 20, "", true, true));
  		$description = trim(Strings::shorten($description, 40, "", true, true));
  
  		$this->cart[] = array(
  			"name" => $name,
  			"quantity" => $quantity,
  			"amount" => intval(round($totalAmount)),
  			"description" => $description
  		);
  
  		return $this;
  	}
code_tokens: function addCartItem ( $ name , $ quantity , $ totalAmount , $ description = "" ) { if ( count ( $ this -> cart ) >= 2 ) { throw new Exception ( "This version of banks's API supports only up to 2 cart items in single payment, you can't add any more items." ) ; } if ( ! is_numeric ( $ quantity ) or $ quantity < 1 ) { throw new Exception ( "Invalid quantity: $quantity. It must be numeric and >= 1" ) ; } $ name = trim ( Strings :: shorten ( $ name , 20 , "" , true , true ) ) ; $ description = trim ( Strings :: shorten ( $ description , 40 , "" , true , true ) ) ; $ this -> cart [ ] = array ( "name" => $ name , "quantity" => $ quantity , "amount" => intval ( round ( $ totalAmount ) ) , "description" => $ description ) ; return $ this ; }
docstring: Add one cart item.
  
  You are required to add one or two cart items (at least on API v1).
  
  Remember that $totalAmount must be given in **hundredth of currency units**
  (cents for USD or EUR, "halíře" for CZK)
  
  @param string $name Name that customer will see
  (will be automatically trimmed to 20 characters)
  @param number $quantity
  @param number $totalAmount Total price (total sum for all $quantity),
  in **hundredths** of currency unit
  @param string $description Aux description (trimmed to 40 chars max)
  
  @return Payment Fluent interface
  
  @throws Exception When more than 2nd cart item is to be added or other argument is invalid
docstring_tokens: Add one cart item .