ArangoDB-PHP-Core API Documentation
  • Namespace
  • Class
  • Deprecated

Namespaces

  • frankmayer
    • ArangoDbPhpCore
      • Api
        • Rest
      • Config
      • Connectors
      • Plugins
      • Protocols
        • Http
      • TraitRepository

Classes

  • frankmayer\ArangoDbPhpCore\Api\Rest\Api
  • frankmayer\ArangoDbPhpCore\Api\Rest\Async
  • frankmayer\ArangoDbPhpCore\Api\Rest\Batch
  • frankmayer\ArangoDbPhpCore\Api\Rest\Collection
  • frankmayer\ArangoDbPhpCore\Api\Rest\Database
  • frankmayer\ArangoDbPhpCore\Api\Rest\Document
  • frankmayer\ArangoDbPhpCore\Api\Rest\DocumentBase
  • frankmayer\ArangoDbPhpCore\Api\Rest\Edge
  • frankmayer\ArangoDbPhpCore\Autoloader
  • frankmayer\ArangoDbPhpCore\Client
  • frankmayer\ArangoDbPhpCore\ClientOptions
  • frankmayer\ArangoDbPhpCore\Config\ConnectionOptions
  • frankmayer\ArangoDbPhpCore\Config\DefaultValues
  • frankmayer\ArangoDbPhpCore\Config\Endpoint
  • frankmayer\ArangoDbPhpCore\Config\UpdatePolicy
  • frankmayer\ArangoDbPhpCore\Connectors\AbstractHttpConnector
  • frankmayer\ArangoDbPhpCore\Plugins\Plugin
  • frankmayer\ArangoDbPhpCore\Plugins\PluginManager
  • frankmayer\ArangoDbPhpCore\Plugins\TestPlugin
  • frankmayer\ArangoDbPhpCore\Plugins\TracerPlugin
  • frankmayer\ArangoDbPhpCore\Protocols\Http\AbstractHttpRequest
  • frankmayer\ArangoDbPhpCore\Protocols\Http\HttpRequest
  • frankmayer\ArangoDbPhpCore\Protocols\Http\HttpResponse

Interfaces

  • frankmayer\ArangoDbPhpCore\Api\ApiInterface
  • frankmayer\ArangoDbPhpCore\Api\RestApiInterface
  • frankmayer\ArangoDbPhpCore\ClientInterface
  • frankmayer\ArangoDbPhpCore\ConnectorInterface
  • frankmayer\ArangoDbPhpCore\Plugins\PluginInterface
  • frankmayer\ArangoDbPhpCore\Protocols\Http\HttpConnectorInterface
  • frankmayer\ArangoDbPhpCore\Protocols\Http\HttpRequestInterface
  • frankmayer\ArangoDbPhpCore\Protocols\Http\HttpResponseInterface
  • frankmayer\ArangoDbPhpCore\Protocols\RequestInterface
  • frankmayer\ArangoDbPhpCore\Protocols\ResponseInterface

Traits

  • frankmayer\ArangoDbPhpCore\Api\Rest\DocumentTrait
  • frankmayer\ArangoDbPhpCore\Api\Rest\EdgeTrait
  • frankmayer\ArangoDbPhpCore\TraitRepository\ClientLogger

Exceptions

  • frankmayer\ArangoDbPhpCore\ClientException
  • frankmayer\ArangoDbPhpCore\ConnectionException
  • frankmayer\ArangoDbPhpCore\Exception
  • frankmayer\ArangoDbPhpCore\ServerException
  1 <?php
  2 /**
  3  * ArangoDB PHP Core Client: client
  4  *
  5  * @author    Frank Mayer
  6  * @copyright Copyright 2013-2015, FRANKMAYER.NET, Athens, Greece
  7  */
  8 
  9 namespace frankmayer\ArangoDbPhpCore\Api\Rest;
 10 
 11 use frankmayer\ArangoDbPhpCore\Client;
 12 use frankmayer\ArangoDbPhpCore\Protocols\RequestInterface;
 13 
 14 
 15 /**
 16  * Class Api
 17  *
 18  * @package frankmayer\ArangoDbPhpCore\Api\Rest
 19  */
 20 class Api
 21 {
 22     const METHOD_GET     = 'GET';
 23     const METHOD_POST    = 'POST';
 24     const METHOD_PUT     = 'PUT';
 25     const METHOD_PATCH   = 'PATCH';
 26     const METHOD_DELETE  = 'DELETE';
 27     const METHOD_HEAD    = 'HEAD';
 28     const METHOD_OPTIONS = 'OPTIONS';
 29 
 30     /**
 31      * @var Client The client instance of this api instance
 32      */
 33     protected $client;
 34 
 35 
 36     /**
 37      * Constructs an api object through which commands can be issued against the server.
 38      * For each API class, only one instance per Client is necessary.
 39      *
 40      * @param $client
 41      */
 42     function __construct($client)
 43     {
 44         $this->client = $client;
 45     }
 46 
 47 
 48     /**
 49      * Returns the correct object, according to the 'isBatchPart' option.
 50      * If it is a Batchpart, it returns the request, else the response.
 51      *
 52      * @param $request
 53      *
 54      * @return mixed
 55      */
 56     protected function getReturnObject($request)
 57     {
 58         if (array_key_exists('isBatchPart', $request->options) && $request->options['isBatchPart'] === true) {
 59             return $request;
 60         } else {
 61             $responseObject = $request->send();
 62 
 63             return $responseObject;
 64         }
 65     }
 66 
 67 
 68     /**
 69      * @return RequestInterface
 70      */
 71     public function getRequest()
 72     {
 73         return $this->client->getRequest();
 74     }
 75 
 76 
 77    /**
 78      * @return ResponseInterface
 79      */
 80     public function getResponse()
 81     {
 82         return $this->client->getResponse();
 83     }
 84 
 85 
 86     /**
 87      * array_merge_recursive does indeed merge arrays, but it converts values with duplicate
 88      * keys to arrays rather than overwriting the value in the first array with the duplicate
 89      * value in the second array, as array_merge does. I.e., with array_merge_recursive,
 90      * this happens (documented behavior):
 91      *
 92      * array_merge_recursive(array('key' => 'org value'), array('key' => 'new value'));
 93      *     => array('key' => array('org value', 'new value'));
 94      *
 95      * array_merge_recursive_distinct does not change the data-types of the values in the arrays.
 96      * Matching keys' values in the second array overwrite those in the first array, as is the
 97      * case with array_merge, i.e.:
 98      *
 99      * array_merge_recursive_distinct(array('key' => 'org value'), array('key' => 'new value'));
100      *     => array('key' => array('new value'));
101      *
102      * Parameters are passed by reference, though only for performance reasons. They're not
103      * altered by this function.
104      *
105      * Note: thanks Gabriel and Daniel for your work. I only made it static ;)
106      *
107      * @param array $array1
108      * @param array $array2
109      *
110      * @return array
111      *
112      * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk>
113      * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com>
114      * @author Frank Mayer
115      */
116     public static function array_merge_recursive_distinct(array $array1, array $array2)
117     {
118         $merged = $array1;
119 
120         foreach ($array2 as $key => &$value) {
121             if (is_array($value) && isset ($merged [$key]) && is_array($merged [$key])) {
122                 $merged [$key] = static::array_merge_recursive_distinct($merged [$key], $value);
123             } else {
124                 $merged [$key] = $value;
125             }
126         }
127 
128         return $merged;
129     }
130 
131 }
132 
ArangoDB-PHP-Core API Documentation API documentation generated by ApiGen