Merge "Move up devunt's name to Developers"
[lhc/web/wiklou.git] / includes / libs / virtualrest / VirtualRESTService.php
index 05c2afc..ccb14db 100644 (file)
@@ -35,7 +35,7 @@
  */
 abstract class VirtualRESTService {
        /** @var array Key/value map */
-       protected $params = array();
+       protected $params = [];
 
        /**
         * @param array $params Key/value map
@@ -44,6 +44,17 @@ abstract class VirtualRESTService {
                $this->params = $params;
        }
 
+       /**
+        * Return the name of this service, in a form suitable for error
+        * reporting or debugging.
+        *
+        * @return string The name of the service behind this VRS object.
+        */
+       public function getName() {
+               return isset( $this->params['name'] ) ? $this->params['name'] :
+                       get_class( $this );
+       }
+
        /**
         * Prepare virtual HTTP(S) requests (for this service) for execution
         *
@@ -67,7 +78,7 @@ abstract class VirtualRESTService {
         * @return array Modified HTTP request array map
         */
        public function onRequests( array $reqs, Closure $idGeneratorFunc ) {
-               $result = array();
+               $result = [];
                foreach ( $reqs as $key => $req ) {
                        // The default encoding treats the URL as a REST style path that uses
                        // forward slash as a hierarchical delimiter (and never otherwise).
@@ -84,8 +95,8 @@ abstract class VirtualRESTService {
         *
         * This method may mangle any of the $reqs entry 'response' fields as needed:
         *   - code    : perform any code normalization [as needed]
-        *   - reason  : perform any reason normalization [as needed]
-        *   - headers : perform any header normalization [as needed]
+        *   - reason  : perform any reason normalization [as needed]
+        *   - headers : perform any header normalization [as needed]
         *
         * This method can also remove some of the requests as well as add new ones
         * (using $idGenerator to set each of the entries' array keys). For any existing