diff --git a/src/Http/Methods.php b/src/Http/Methods.php new file mode 100644 index 0000000..8f5452b --- /dev/null +++ b/src/Http/Methods.php @@ -0,0 +1,147 @@ +method = 'GET'; + return $this; + } + + /** + * @return $this + */ + public function post() + { + $this->method = 'POST'; + return $this; + } + + /** + * @return $this + */ + public function put() + { + $this->method = 'PUT'; + return $this; + } + + /** + * @return $this + */ + public function delete() + { + $this->method = 'DELETE'; + return $this; + } + + /** + * @return $this + */ + public function patch() + { + $this->method = 'PATCH'; + return $this; + } + + /** + * @return $this + */ + public function copy() + { + $this->method = 'COPY'; + return $this; + } + + /** + * @return $this + */ + public function head() + { + $this->method = 'HEAD'; + return $this; + } + + /** + * @return $this + */ + public function options() + { + $this->method = 'OPTIONS'; + return $this; + } + + /** + * @return $this + */ + public function link() + { + $this->method = 'LINK'; + return $this; + } + + /** + * @return $this + */ + public function unlink() + { + $this->method = 'UNLINK'; + return $this; + } + + /** + * @return $this + */ + public function purge() + { + $this->method = 'PURGE'; + return $this; + } + + /** + * @return $this + */ + public function lock() + { + $this->method = 'LOCK'; + return $this; + } + + /** + * @return $this + */ + public function unlock() + { + $this->method = 'UNLOCK'; + return $this; + } + + /** + * @return $this + */ + public function propfind() + { + $this->method = 'PROPFIND'; + return $this; + } + + /** + * @return $this + */ + public function view() + { + $this->method = 'VIEW'; + return $this; + } +} \ No newline at end of file diff --git a/src/Rest.php b/src/Rest.php index 7d1f7fb..5cc99de 100644 --- a/src/Rest.php +++ b/src/Rest.php @@ -10,9 +10,12 @@ use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; +use Maestro\Http\Methods; class Rest { + use Methods; + protected $url; private $endPoint; private $method; @@ -57,141 +60,6 @@ public function setEndPoint(string $endPoint) return $this; } - /** - * @return $this - */ - public function get() - { - $this->method = 'GET'; - return $this; - } - - /** - * @return $this - */ - public function post() - { - $this->method = 'POST'; - return $this; - } - - /** - * @return $this - */ - public function put() - { - $this->method = 'PUT'; - return $this; - } - - /** - * @return $this - */ - public function delete() - { - $this->method = 'DELETE'; - return $this; - } - - /** - * @return $this - */ - public function patch() - { - $this->method = 'PATCH'; - return $this; - } - - /** - * @return $this - */ - public function copy() - { - $this->method = 'COPY'; - return $this; - } - - /** - * @return $this - */ - public function head() - { - $this->method = 'HEAD'; - return $this; - } - - /** - * @return $this - */ - public function options() - { - $this->method = 'OPTIONS'; - return $this; - } - - /** - * @return $this - */ - public function link() - { - $this->method = 'LINK'; - return $this; - } - - /** - * @return $this - */ - public function unlink() - { - $this->method = 'UNLINK'; - return $this; - } - - /** - * @return $this - */ - public function purge() - { - $this->method = 'PURGE'; - return $this; - } - - /** - * @return $this - */ - public function lock() - { - $this->method = 'LOCK'; - return $this; - } - - /** - * @return $this - */ - public function unlock() - { - $this->method = 'UNLOCK'; - return $this; - } - - /** - * @return $this - */ - public function propfind() - { - $this->method = 'PROPFIND'; - return $this; - } - - /** - * @return $this - */ - public function view() - { - $this->method = 'VIEW'; - return $this; - } - /** * @return $this */ diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29