summaryrefslogtreecommitdiff
path: root/vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
committerFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
commit9e2b2a32fd0e967ad3184e9a5d091a29953acb91 (patch)
tree00822e24aa1110c73ca455a8d096ef296c008cbc /vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php
parentc507c5416251c505cb3e088a03c6664bed73c812 (diff)
Include composer dependencies in repo
Diffstat (limited to 'vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php')
-rw-r--r--vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php114
1 files changed, 114 insertions, 0 deletions
diff --git a/vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php b/vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php
new file mode 100644
index 00000000..61d5a2d2
--- /dev/null
+++ b/vendor/fguillot/json-rpc/src/JsonRPC/MiddlewareHandler.php
@@ -0,0 +1,114 @@
+<?php
+
+namespace JsonRPC;
+
+/**
+ * Class MiddlewareHandler
+ *
+ * @package JsonRPC
+ * @author Frederic Guillot
+ */
+class MiddlewareHandler
+{
+ /**
+ * Procedure Name
+ *
+ * @access protected
+ * @var string
+ */
+ protected $procedureName = '';
+
+ /**
+ * Username
+ *
+ * @access protected
+ * @var string
+ */
+ protected $username = '';
+
+ /**
+ * Password
+ *
+ * @access protected
+ * @var string
+ */
+ protected $password = '';
+
+ /**
+ * List of middleware to execute before to call the method
+ *
+ * @access protected
+ * @var MiddlewareInterface[]
+ */
+ protected $middleware = array();
+
+ /**
+ * Set username
+ *
+ * @access public
+ * @param string $username
+ * @return $this
+ */
+ public function withUsername($username)
+ {
+ if (! empty($username)) {
+ $this->username = $username;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set password
+ *
+ * @access public
+ * @param string $password
+ * @return $this
+ */
+ public function withPassword($password)
+ {
+ if (! empty($password)) {
+ $this->password = $password;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set procedure name
+ *
+ * @access public
+ * @param string $procedureName
+ * @return $this
+ */
+ public function withProcedure($procedureName)
+ {
+ $this->procedureName = $procedureName;
+ return $this;
+ }
+
+ /**
+ * Add a new middleware
+ *
+ * @access public
+ * @param MiddlewareInterface $middleware
+ * @return MiddlewareHandler
+ */
+ public function withMiddleware(MiddlewareInterface $middleware)
+ {
+ $this->middleware[] = $middleware;
+ return $this;
+ }
+
+ /**
+ * Execute all middleware
+ *
+ * @access public
+ */
+ public function execute()
+ {
+ foreach ($this->middleware as $middleware) {
+ $middleware->execute($this->username, $this->password, $this->procedureName);
+ }
+ }
+}