PayPalApiPatchRequest

Class PatchRequest.

Defined (1)

The class is defined in the following location(s).

/classes/lib/PayPal/Api/PatchRequest.php  
  1. class PatchRequest extends PayPalModel 
  2. /** 
  3. * Placeholder for holding array of patch objects 
  4. * @param \PayPal\Api\Patch[] $patches 
  5. *  
  6. * @return $this 
  7. */ 
  8. public function setPatches($patches) 
  9. $this->patches = $patches; 
  10. return $this; 
  11.  
  12. /** 
  13. * Placeholder for holding array of patch objects 
  14. * @return \PayPal\Api\Patch[] 
  15. */ 
  16. public function getPatches() 
  17. return $this->patches; 
  18.  
  19. /** 
  20. * Append Patches to the list. 
  21. * @param \PayPal\Api\Patch $patch 
  22. * @return $this 
  23. */ 
  24. public function addPatch($patch) 
  25. if (!$this->getPatches()) { 
  26. return $this->setPatches(array($patch)); 
  27. } else { 
  28. return $this->setPatches( 
  29. array_merge($this->getPatches(), array($patch)) 
  30. ); 
  31.  
  32. /** 
  33. * Remove Patches from the list. 
  34. * @param \PayPal\Api\Patch $patch 
  35. * @return $this 
  36. */ 
  37. public function removePatch($patch) 
  38. return $this->setPatches( 
  39. array_diff($this->getPatches(), array($patch)) 
  40. ); 
  41.  
  42. /** 
  43. * As PatchRequest holds the array of Patch object, we would override the json conversion to return 
  44. * a json representation of array of Patch objects. 
  45. * @param int $options 
  46. * @return mixed|string 
  47. */ 
  48. public function toJSON($options = 0) 
  49. $json = array(); 
  50. foreach ($this->getPatches() as $patch) { 
  51. $json[] = $patch->toArray(); 
  52. return str_replace('\\/', '/', json_encode($json, $options));