Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
Add trait for Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-campos committed Oct 18, 2017
1 parent 653dbbf commit b2749cb
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 135 deletions.
147 changes: 147 additions & 0 deletions src/Http/Methods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php

/**
* User: marcus-campos
* Date: 18/10/17
* Time: 14:24
*/

namespace Maestro\Http;

trait Methods
{
/**
* @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;
}
}
138 changes: 3 additions & 135 deletions src/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down
Empty file added tests/.gitkeep
Empty file.

0 comments on commit b2749cb

Please sign in to comment.