12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace Braintree;
- use JsonSerializable;
- /**
- * Braintree PHP Library.
- *
- * Braintree base class and initialization
- * Provides methods to child classes. This class cannot be instantiated.
- *
- * PHP version 5
- */
- abstract class Base implements JsonSerializable
- {
- protected $_attributes = [];
- /**
- * @ignore
- * don't permit an explicit call of the constructor!
- * (like $t = new Transaction())
- */
- protected function __construct()
- {
- }
- /**
- * Disable cloning of objects
- *
- * @ignore
- */
- protected function __clone()
- {
- }
- /**
- * Accessor for instance properties stored in the private $_attributes property
- *
- * @ignore
- * @param string $name
- * @return mixed
- */
- public function __get($name)
- {
- if (array_key_exists($name, $this->_attributes)) {
- return $this->_attributes[$name];
- }
- else {
- trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
- return null;
- }
- }
- /**
- * Checks for the existance of a property stored in the private $_attributes property
- *
- * @ignore
- * @param string $name
- * @return boolean
- */
- public function __isset($name)
- {
- return array_key_exists($name, $this->_attributes);
- }
- /**
- * Mutator for instance properties stored in the private $_attributes property
- *
- * @ignore
- * @param string $key
- * @param mixed $value
- */
- public function _set($key, $value)
- {
- $this->_attributes[$key] = $value;
- }
-
- /**
- * Implementation of JsonSerializable
- *
- * @ignore
- * @return array
- */
- public function jsonSerialize()
- {
- return $this->_attributes;
- }
- }
|