Skip to content

Commit

Permalink
remove deprecated stuff, misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anlutro committed Jul 3, 2015
1 parent cfadc6b commit 87178fb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 62 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Simple PHP cURL wrapper class
# php-curl

The smallest possible OOP wrapper for PHP's curl capabilities.

## Installation

$ composer require anlutro/curl

Note that while on version 0.x I will not guarantee backwards compatibility between minor versions. Specify the version in your composer.json if you don't want/need to keep up with new features, or use a more mature library like [Guzzle](https://github.com/guzzle/guzzle).

## Usage

```php
Expand Down
19 changes: 0 additions & 19 deletions src/Laravel/cURLServiceProvider.php

This file was deleted.

35 changes: 11 additions & 24 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,12 @@ public function getUserAndPass()
public function encodeData()
{
switch ($this->encoding) {
case Request::ENCODING_JSON:
case static::ENCODING_JSON:
return json_encode($this->data);

case Request::ENCODING_RAW:
return $this->data;

case Request::ENCODING_QUERY:
case static::ENCODING_QUERY:
return http_build_query($this->data);

case static::ENCODING_RAW:
return $this->data;
default:
throw new \UnexpectedValueException("Encoding [$encoding] not a known Request::ENCODING_* constant");
}
Expand All @@ -348,7 +345,7 @@ public function encodeData()
*/
public function isJson()
{
return $this->encoding === Request::ENCODING_JSON;
return $this->encoding === static::ENCODING_JSON;
}

/**
Expand All @@ -360,11 +357,15 @@ public function setEncoding($encoding)
{
$encoding = intval($encoding);

if ($encoding !== REQUEST::ENCODING_QUERY && $encoding !== REQUEST::ENCODING_JSON && $encoding !== REQUEST::ENCODING_RAW) {
if (
$encoding !== static::ENCODING_QUERY &&
$encoding !== static::ENCODING_JSON &&
$encoding !== static::ENCODING_RAW
) {
throw new \InvalidArgumentException("Encoding [$encoding] not a known Request::ENCODING_* constant");
}

if ($encoding === Request::ENCODING_JSON && !$this->getHeader('Content-Type')) {
if ($encoding === static::ENCODING_JSON && !$this->getHeader('Content-Type')) {
$this->setHeader('Content-Type', 'application/json');
}

Expand All @@ -381,20 +382,6 @@ public function getEncoding()
return $this->encoding;
}

/**
* Set whether the response should be JSON or not.
*
* @param boolean $toggle
*
* @deprecated Use setEncoding(Request::ENCODING_JSON)
*/
public function setJson($toggle)
{
$this->setEncoding($toggle ? Request::ENCODING_JSON : Request::ENCODING_QUERY);

return $this;
}

/**
* Send the request.
*
Expand Down
7 changes: 0 additions & 7 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ class Response
*/
public $info;

/**
* @deprecated
* @see $statusText, $statusCode
*/
public $code;

/**
* The response code including text, e.g. '200 OK'.
*
Expand Down Expand Up @@ -80,7 +74,6 @@ public function __construct($body, $headers, $info = array())
*/
protected function setCode($code)
{
$this->code = $code;
$this->statusText = $code;
list($this->statusCode, ) = explode(' ', $code);
}
Expand Down
8 changes: 0 additions & 8 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ public function testEncodeData()
$this->assertEquals('<rawData>ArbitraryValue</rawData>', $r->encodeData());
}

public function testJsonConvenienceMethod()
{
$r = $this->makeRequest();

$r->setJson(true);
$this->assertEquals(Request::ENCODING_JSON, $r->getEncoding());
}

public function testFormatHeaders()
{
$r = $this->makeRequest();
Expand Down
3 changes: 2 additions & 1 deletion tests/cURLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public function testRealWebsite()

$r = $curl->get('http://php.net');

$this->assertEquals('200 OK', $r->code);
$this->assertEquals(200, $r->statusCode);
$this->assertEquals('200 OK', $r->statusText);
$this->assertNotNull($r->body);
$this->assertNotNull($r->headers);
$this->assertNotNull($r->info);
Expand Down

0 comments on commit 87178fb

Please sign in to comment.