@@ -8,8 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | namespace Httpful\Handlers; |
| 10 | 10 | |
| 11 | -class XHtmlHandler extends MimeHandlerAdapter |
|
| 12 | -{ |
|
| 11 | +class XHtmlHandler extends MimeHandlerAdapter { |
|
| 13 | 12 | // @todo add html specific parsing |
| 14 | 13 | // see DomDocument::load http://docs.php.net/manual/en/domdocument.loadhtml.php |
| 15 | 14 | } |
| 16 | 15 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class MimeHandlerAdapter |
| 12 | 12 | { |
| 13 | - public function __construct(array $args = array()) |
|
| 13 | + public function __construct(array $args = array ()) |
|
| 14 | 14 | { |
| 15 | 15 | $this->init($args); |
| 16 | 16 | } |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | protected function stripBom($body) |
| 45 | 45 | { |
| 46 | - if ( substr($body,0,3) === "\xef\xbb\xbf" ) // UTF-8 |
|
| 47 | - $body = substr($body,3); |
|
| 48 | - else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) // UTF-32 |
|
| 49 | - $body = substr($body,4); |
|
| 50 | - else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) // UTF-16 |
|
| 51 | - $body = substr($body,2); |
|
| 46 | + if (substr($body, 0, 3) === "\xef\xbb\xbf") // UTF-8 |
|
| 47 | + $body = substr($body, 3); |
|
| 48 | + else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" || substr($body, 0, 4) === "\x00\x00\xfe\xff") // UTF-32 |
|
| 49 | + $body = substr($body, 4); |
|
| 50 | + else if (substr($body, 0, 2) === "\xff\xfe" || substr($body, 0, 2) === "\xfe\xff") // UTF-16 |
|
| 51 | + $body = substr($body, 2); |
|
| 52 | 52 | return $body; |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -8,10 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace Httpful\Handlers; |
| 10 | 10 | |
| 11 | -class MimeHandlerAdapter |
|
| 12 | -{ |
|
| 13 | - public function __construct(array $args = array()) |
|
| 14 | - { |
|
| 11 | +class MimeHandlerAdapter { |
|
| 12 | + public function __construct(array $args = array()) { |
|
| 15 | 13 | $this->init($args); |
| 16 | 14 | } |
| 17 | 15 | |
@@ -19,16 +17,14 @@ discard block |
||
| 19 | 17 | * Initial setup of |
| 20 | 18 | * @param array $args |
| 21 | 19 | */ |
| 22 | - public function init(array $args) |
|
| 23 | - { |
|
| 20 | + public function init(array $args) { |
|
| 24 | 21 | } |
| 25 | 22 | |
| 26 | 23 | /** |
| 27 | 24 | * @param string $body |
| 28 | 25 | * @return mixed |
| 29 | 26 | */ |
| 30 | - public function parse($body) |
|
| 31 | - { |
|
| 27 | + public function parse($body) { |
|
| 32 | 28 | return $body; |
| 33 | 29 | } |
| 34 | 30 | |
@@ -36,19 +32,21 @@ discard block |
||
| 36 | 32 | * @param mixed $payload |
| 37 | 33 | * @return string |
| 38 | 34 | */ |
| 39 | - function serialize($payload) |
|
| 40 | - { |
|
| 35 | + function serialize($payload) { |
|
| 41 | 36 | return (string) $payload; |
| 42 | 37 | } |
| 43 | 38 | |
| 44 | - protected function stripBom($body) |
|
| 45 | - { |
|
| 46 | - if ( substr($body,0,3) === "\xef\xbb\xbf" ) // UTF-8 |
|
| 39 | + protected function stripBom($body) { |
|
| 40 | + if ( substr($body,0,3) === "\xef\xbb\xbf" ) { |
|
| 41 | + // UTF-8 |
|
| 47 | 42 | $body = substr($body,3); |
| 48 | - else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) // UTF-32 |
|
| 43 | + } else if ( substr($body,0,4) === "\xff\xfe\x00\x00" || substr($body,0,4) === "\x00\x00\xfe\xff" ) { |
|
| 44 | + // UTF-32 |
|
| 49 | 45 | $body = substr($body,4); |
| 50 | - else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) // UTF-16 |
|
| 46 | + } else if ( substr($body,0,2) === "\xff\xfe" || substr($body,0,2) === "\xfe\xff" ) { |
|
| 47 | + // UTF-16 |
|
| 51 | 48 | $body = substr($body,2); |
| 49 | + } |
|
| 52 | 50 | return $body; |
| 53 | 51 | } |
| 54 | 52 | } |
| 55 | 53 | \ No newline at end of file |
@@ -6,12 +6,10 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | namespace Httpful\Handlers; |
| 8 | 8 | |
| 9 | -class JsonHandler extends MimeHandlerAdapter |
|
| 10 | -{ |
|
| 9 | +class JsonHandler extends MimeHandlerAdapter { |
|
| 11 | 10 | private $decode_as_array = false; |
| 12 | 11 | |
| 13 | - public function init(array $args) |
|
| 14 | - { |
|
| 12 | + public function init(array $args) { |
|
| 15 | 13 | $this->decode_as_array = !!(array_key_exists('decode_as_array', $args) ? $args['decode_as_array'] : false); |
| 16 | 14 | } |
| 17 | 15 | |
@@ -19,14 +17,15 @@ discard block |
||
| 19 | 17 | * @param string $body |
| 20 | 18 | * @return mixed |
| 21 | 19 | */ |
| 22 | - public function parse($body) |
|
| 23 | - { |
|
| 20 | + public function parse($body) { |
|
| 24 | 21 | $body = $this->stripBom($body); |
| 25 | - if (empty($body)) |
|
| 26 | - return null; |
|
| 22 | + if (empty($body)) { |
|
| 23 | + return null; |
|
| 24 | + } |
|
| 27 | 25 | $parsed = json_decode($body, $this->decode_as_array); |
| 28 | - if (is_null($parsed) && 'null' !== strtolower($body)) |
|
| 29 | - throw new \Exception("Unable to parse response as JSON"); |
|
| 26 | + if (is_null($parsed) && 'null' !== strtolower($body)) { |
|
| 27 | + throw new \Exception("Unable to parse response as JSON"); |
|
| 28 | + } |
|
| 30 | 29 | return $parsed; |
| 31 | 30 | } |
| 32 | 31 | |
@@ -34,8 +33,7 @@ discard block |
||
| 34 | 33 | * @param mixed $payload |
| 35 | 34 | * @return string |
| 36 | 35 | */ |
| 37 | - public function serialize($payload) |
|
| 38 | - { |
|
| 36 | + public function serialize($payload) { |
|
| 39 | 37 | return json_encode($payload); |
| 40 | 38 | } |
| 41 | 39 | } |
@@ -8,11 +8,11 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class JsonHandler extends MimeHandlerAdapter |
| 10 | 10 | { |
| 11 | - private $decode_as_array = false; |
|
| 11 | + private $decode_as_array = FALSE; |
|
| 12 | 12 | |
| 13 | 13 | public function init(array $args) |
| 14 | 14 | { |
| 15 | - $this->decode_as_array = !!(array_key_exists('decode_as_array', $args) ? $args['decode_as_array'] : false); |
|
| 15 | + $this->decode_as_array = !!(array_key_exists('decode_as_array', $args) ? $args['decode_as_array'] : FALSE); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $body = $this->stripBom($body); |
| 25 | 25 | if (empty($body)) |
| 26 | - return null; |
|
| 26 | + return NULL; |
|
| 27 | 27 | $parsed = json_decode($body, $this->decode_as_array); |
| 28 | 28 | if (is_null($parsed) && 'null' !== strtolower($body)) |
| 29 | 29 | throw new \Exception("Unable to parse response as JSON"); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | if (empty($body)) |
| 18 | 18 | return null; |
| 19 | 19 | |
| 20 | - $parsed = array(); |
|
| 20 | + $parsed = array (); |
|
| 21 | 21 | $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
| 22 | 22 | while (($r = fgetcsv($fp)) !== FALSE) { |
| 23 | 23 | $parsed[] = $r; |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function serialize($payload) |
| 36 | 36 | { |
| 37 | - $fp = fopen('php://temp/maxmemory:'. (6*1024*1024), 'r+'); |
|
| 37 | + $fp = fopen('php://temp/maxmemory:' . (6 * 1024 * 1024), 'r+'); |
|
| 38 | 38 | $i = 0; |
| 39 | 39 | foreach ($payload as $fields) { |
| 40 | - if($i++ == 0) { |
|
| 40 | + if ($i++ == 0) { |
|
| 41 | 41 | fputcsv($fp, array_keys($fields)); |
| 42 | 42 | } |
| 43 | 43 | fputcsv($fp, $fields); |
@@ -6,16 +6,15 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | namespace Httpful\Handlers; |
| 8 | 8 | |
| 9 | -class CsvHandler extends MimeHandlerAdapter |
|
| 10 | -{ |
|
| 9 | +class CsvHandler extends MimeHandlerAdapter { |
|
| 11 | 10 | /** |
| 12 | 11 | * @param string $body |
| 13 | 12 | * @return mixed |
| 14 | 13 | */ |
| 15 | - public function parse($body) |
|
| 16 | - { |
|
| 17 | - if (empty($body)) |
|
| 18 | - return null; |
|
| 14 | + public function parse($body) { |
|
| 15 | + if (empty($body)) { |
|
| 16 | + return null; |
|
| 17 | + } |
|
| 19 | 18 | |
| 20 | 19 | $parsed = array(); |
| 21 | 20 | $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
@@ -23,8 +22,9 @@ discard block |
||
| 23 | 22 | $parsed[] = $r; |
| 24 | 23 | } |
| 25 | 24 | |
| 26 | - if (empty($parsed)) |
|
| 27 | - throw new \Exception("Unable to parse response as CSV"); |
|
| 25 | + if (empty($parsed)) { |
|
| 26 | + throw new \Exception("Unable to parse response as CSV"); |
|
| 27 | + } |
|
| 28 | 28 | return $parsed; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | * @param mixed $payload |
| 33 | 33 | * @return string |
| 34 | 34 | */ |
| 35 | - public function serialize($payload) |
|
| 36 | - { |
|
| 35 | + public function serialize($payload) { |
|
| 37 | 36 | $fp = fopen('php://temp/maxmemory:'. (6*1024*1024), 'r+'); |
| 38 | 37 | $i = 0; |
| 39 | 38 | foreach ($payload as $fields) { |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function parse($body) |
| 16 | 16 | { |
| 17 | 17 | if (empty($body)) |
| 18 | - return null; |
|
| 18 | + return NULL; |
|
| 19 | 19 | |
| 20 | 20 | $parsed = array(); |
| 21 | 21 | $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r'); |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @param array $conf sets configuration options |
| 25 | 25 | */ |
| 26 | - public function __construct(array $conf = array()) |
|
| 26 | + public function __construct(array $conf = array ()) |
|
| 27 | 27 | { |
| 28 | - $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
| 29 | - $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
| 28 | + $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
|
| 29 | + $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $xml = new \XMLWriter; |
| 67 | 67 | $xml->openMemory(); |
| 68 | - $xml->startDocument('1.0','ISO-8859-1'); |
|
| 68 | + $xml->startDocument('1.0', 'ISO-8859-1'); |
|
| 69 | 69 | $this->serialize_node($xml, $payload); |
| 70 | 70 | return $xml->outputMemory(true); |
| 71 | 71 | } |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @param mixed $node to serialize |
| 76 | 76 | * @author Ted Zellers |
| 77 | 77 | */ |
| 78 | - public function serialize_node(&$xmlw, $node){ |
|
| 79 | - if (!is_array($node)){ |
|
| 78 | + public function serialize_node(&$xmlw, $node) { |
|
| 79 | + if (!is_array($node)) { |
|
| 80 | 80 | $xmlw->text($node); |
| 81 | 81 | } else { |
| 82 | - foreach ($node as $k => $v){ |
|
| 82 | + foreach ($node as $k => $v) { |
|
| 83 | 83 | $xmlw->startElement($k); |
| 84 | 84 | $this->serialize_node($xmlw, $v); |
| 85 | 85 | $xmlw->endElement(); |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | $node->appendChild($arrNode); |
| 113 | 113 | $this->_future_serializeArrayAsXml($value, $arrNode, $dom); |
| 114 | 114 | } else if (is_bool($value)) { |
| 115 | - $node->appendChild($dom->createTextNode($value?'TRUE':'FALSE')); |
|
| 115 | + $node->appendChild($dom->createTextNode($value ? 'TRUE' : 'FALSE')); |
|
| 116 | 116 | } else { |
| 117 | 117 | $node->appendChild($dom->createTextNode($value)); |
| 118 | 118 | } |
| 119 | - return array($node, $dom); |
|
| 119 | + return array ($node, $dom); |
|
| 120 | 120 | } |
| 121 | 121 | /** |
| 122 | 122 | * @author Zack Douglas <[email protected]> |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $parent->appendChild($el); |
| 133 | 133 | $this->_future_serializeAsXml($v, $el, $dom); |
| 134 | 134 | } |
| 135 | - return array($parent, $dom); |
|
| 135 | + return array ($parent, $dom); |
|
| 136 | 136 | } |
| 137 | 137 | /** |
| 138 | 138 | * @author Zack Douglas <[email protected]> |
@@ -147,6 +147,6 @@ discard block |
||
| 147 | 147 | $this->_future_serializeAsXml($pr->getValue($value), $el, $dom); |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - return array($parent, $dom); |
|
| 150 | + return array ($parent, $dom); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | \ No newline at end of file |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace Httpful\Handlers; |
| 10 | 10 | |
| 11 | -class XmlHandler extends MimeHandlerAdapter |
|
| 12 | -{ |
|
| 11 | +class XmlHandler extends MimeHandlerAdapter { |
|
| 13 | 12 | /** |
| 14 | 13 | * @var string $namespace xml namespace to use with simple_load_string |
| 15 | 14 | */ |
@@ -23,8 +22,7 @@ discard block |
||
| 23 | 22 | /** |
| 24 | 23 | * @param array $conf sets configuration options |
| 25 | 24 | */ |
| 26 | - public function __construct(array $conf = array()) |
|
| 27 | - { |
|
| 25 | + public function __construct(array $conf = array()) { |
|
| 28 | 26 | $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : ''; |
| 29 | 27 | $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0; |
| 30 | 28 | } |
@@ -34,14 +32,15 @@ discard block |
||
| 34 | 32 | * @return mixed |
| 35 | 33 | * @throws Exception if unable to parse |
| 36 | 34 | */ |
| 37 | - public function parse($body) |
|
| 38 | - { |
|
| 35 | + public function parse($body) { |
|
| 39 | 36 | $body = $this->stripBom($body); |
| 40 | - if (empty($body)) |
|
| 41 | - return null; |
|
| 37 | + if (empty($body)) { |
|
| 38 | + return null; |
|
| 39 | + } |
|
| 42 | 40 | $parsed = simplexml_load_string($body, null, $this->libxml_opts, $this->namespace); |
| 43 | - if ($parsed === false) |
|
| 44 | - throw new \Exception("Unable to parse response as XML"); |
|
| 41 | + if ($parsed === false) { |
|
| 42 | + throw new \Exception("Unable to parse response as XML"); |
|
| 43 | + } |
|
| 45 | 44 | return $parsed; |
| 46 | 45 | } |
| 47 | 46 | |
@@ -50,8 +49,7 @@ discard block |
||
| 50 | 49 | * @return string |
| 51 | 50 | * @throws Exception if unable to serialize |
| 52 | 51 | */ |
| 53 | - public function serialize($payload) |
|
| 54 | - { |
|
| 52 | + public function serialize($payload) { |
|
| 55 | 53 | list($_, $dom) = $this->_future_serializeAsXml($payload); |
| 56 | 54 | return $dom->saveXml(); |
| 57 | 55 | } |
@@ -61,8 +59,7 @@ discard block |
||
| 61 | 59 | * @return string |
| 62 | 60 | * @author Ted Zellers |
| 63 | 61 | */ |
| 64 | - public function serialize_clean($payload) |
|
| 65 | - { |
|
| 62 | + public function serialize_clean($payload) { |
|
| 66 | 63 | $xml = new \XMLWriter; |
| 67 | 64 | $xml->openMemory(); |
| 68 | 65 | $xml->startDocument('1.0','ISO-8859-1'); |
@@ -75,11 +72,11 @@ discard block |
||
| 75 | 72 | * @param mixed $node to serialize |
| 76 | 73 | * @author Ted Zellers |
| 77 | 74 | */ |
| 78 | - public function serialize_node(&$xmlw, $node){ |
|
| 79 | - if (!is_array($node)){ |
|
| 75 | + public function serialize_node(&$xmlw, $node) { |
|
| 76 | + if (!is_array($node)) { |
|
| 80 | 77 | $xmlw->text($node); |
| 81 | 78 | } else { |
| 82 | - foreach ($node as $k => $v){ |
|
| 79 | + foreach ($node as $k => $v) { |
|
| 83 | 80 | $xmlw->startElement($k); |
| 84 | 81 | $this->serialize_node($xmlw, $v); |
| 85 | 82 | $xmlw->endElement(); |
@@ -90,8 +87,7 @@ discard block |
||
| 90 | 87 | /** |
| 91 | 88 | * @author Zack Douglas <[email protected]> |
| 92 | 89 | */ |
| 93 | - private function _future_serializeAsXml($value, $node = null, $dom = null) |
|
| 94 | - { |
|
| 90 | + private function _future_serializeAsXml($value, $node = null, $dom = null) { |
|
| 95 | 91 | if (!$dom) { |
| 96 | 92 | $dom = new \DOMDocument; |
| 97 | 93 | } |
@@ -121,8 +117,7 @@ discard block |
||
| 121 | 117 | /** |
| 122 | 118 | * @author Zack Douglas <[email protected]> |
| 123 | 119 | */ |
| 124 | - private function _future_serializeArrayAsXml($value, &$parent, &$dom) |
|
| 125 | - { |
|
| 120 | + private function _future_serializeArrayAsXml($value, &$parent, &$dom) { |
|
| 126 | 121 | foreach ($value as $k => &$v) { |
| 127 | 122 | $n = $k; |
| 128 | 123 | if (is_numeric($k)) { |
@@ -137,8 +132,7 @@ discard block |
||
| 137 | 132 | /** |
| 138 | 133 | * @author Zack Douglas <[email protected]> |
| 139 | 134 | */ |
| 140 | - private function _future_serializeObjectAsXml($value, &$parent, &$dom) |
|
| 141 | - { |
|
| 135 | + private function _future_serializeObjectAsXml($value, &$parent, &$dom) { |
|
| 142 | 136 | $refl = new \ReflectionObject($value); |
| 143 | 137 | foreach ($refl->getProperties() as $pr) { |
| 144 | 138 | if (!$pr->isPrivate()) { |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $body = $this->stripBom($body); |
| 40 | 40 | if (empty($body)) |
| 41 | - return null; |
|
| 42 | - $parsed = simplexml_load_string($body, null, $this->libxml_opts, $this->namespace); |
|
| 43 | - if ($parsed === false) |
|
| 41 | + return NULL; |
|
| 42 | + $parsed = simplexml_load_string($body, NULL, $this->libxml_opts, $this->namespace); |
|
| 43 | + if ($parsed === FALSE) |
|
| 44 | 44 | throw new \Exception("Unable to parse response as XML"); |
| 45 | 45 | return $parsed; |
| 46 | 46 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $xml->openMemory(); |
| 68 | 68 | $xml->startDocument('1.0','ISO-8859-1'); |
| 69 | 69 | $this->serialize_node($xml, $payload); |
| 70 | - return $xml->outputMemory(true); |
|
| 70 | + return $xml->outputMemory(TRUE); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * @author Zack Douglas <[email protected]> |
| 92 | 92 | */ |
| 93 | - private function _future_serializeAsXml($value, $node = null, $dom = null) |
|
| 93 | + private function _future_serializeAsXml($value, $node = NULL, $dom = NULL) |
|
| 94 | 94 | { |
| 95 | 95 | if (!$dom) { |
| 96 | 96 | $dom = new \DOMDocument; |
@@ -2,6 +2,5 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Httpful\Exception; |
| 4 | 4 | |
| 5 | -class ConnectionErrorException extends \Exception |
|
| 6 | -{ |
|
| 5 | +class ConnectionErrorException extends \Exception { |
|
| 7 | 6 | } |
| 8 | 7 | \ No newline at end of file |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * Map short name for a mime type |
| 24 | 24 | * to a full proper mime type |
| 25 | 25 | */ |
| 26 | - public static $mimes = array( |
|
| 26 | + public static $mimes = array ( |
|
| 27 | 27 | 'json' => self::JSON, |
| 28 | 28 | 'xml' => self::XML, |
| 29 | 29 | 'form' => self::FORM, |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | * Class to organize the Mime stuff a bit more |
| 7 | 7 | * @author Nate Good <[email protected]> |
| 8 | 8 | */ |
| 9 | -class Mime |
|
| 10 | -{ |
|
| 9 | +class Mime { |
|
| 11 | 10 | const JSON = 'application/json'; |
| 12 | 11 | const XML = 'application/xml'; |
| 13 | 12 | const XHTML = 'application/html+xml'; |
@@ -44,8 +43,7 @@ discard block |
||
| 44 | 43 | * @return string full mime type (e.g. application/json) |
| 45 | 44 | * @param string common name for mime type (e.g. json) |
| 46 | 45 | */ |
| 47 | - public static function getFullMime($short_name) |
|
| 48 | - { |
|
| 46 | + public static function getFullMime($short_name) { |
|
| 49 | 47 | return array_key_exists($short_name, self::$mimes) ? self::$mimes[$short_name] : $short_name; |
| 50 | 48 | } |
| 51 | 49 | |
@@ -53,8 +51,7 @@ discard block |
||
| 53 | 51 | * @return bool |
| 54 | 52 | * @param string $short_name |
| 55 | 53 | */ |
| 56 | - public static function supportsMimeType($short_name) |
|
| 57 | - { |
|
| 54 | + public static function supportsMimeType($short_name) { |
|
| 58 | 55 | return array_key_exists($short_name, self::$mimes); |
| 59 | 56 | } |
| 60 | 57 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function safeMethods() |
| 23 | 23 | { |
| 24 | - return array(self::HEAD, self::GET, self::OPTIONS, self::TRACE); |
|
| 24 | + return array (self::HEAD, self::GET, self::OPTIONS, self::TRACE); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | // Though it is possible to be idempotent, POST |
| 51 | 51 | // is not guarunteed to be, and more often than |
| 52 | 52 | // not, it is not. |
| 53 | - return array(self::HEAD, self::GET, self::PUT, self::DELETE, self::OPTIONS, self::TRACE, self::PATCH); |
|
| 53 | + return array (self::HEAD, self::GET, self::PUT, self::DELETE, self::OPTIONS, self::TRACE, self::PATCH); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function canHaveBody() |
| 82 | 82 | { |
| 83 | - return array(self::POST, self::PUT, self::PATCH, self::OPTIONS); |
|
| 83 | + return array (self::POST, self::PUT, self::PATCH, self::OPTIONS); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | \ No newline at end of file |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | /** |
| 6 | 6 | * @author Nate Good <[email protected]> |
| 7 | 7 | */ |
| 8 | -class Http |
|
| 9 | -{ |
|
| 8 | +class Http { |
|
| 10 | 9 | const HEAD = 'HEAD'; |
| 11 | 10 | const GET = 'GET'; |
| 12 | 11 | const POST = 'POST'; |
@@ -19,8 +18,7 @@ discard block |
||
| 19 | 18 | /** |
| 20 | 19 | * @return array of HTTP method strings |
| 21 | 20 | */ |
| 22 | - public static function safeMethods() |
|
| 23 | - { |
|
| 21 | + public static function safeMethods() { |
|
| 24 | 22 | return array(self::HEAD, self::GET, self::OPTIONS, self::TRACE); |
| 25 | 23 | } |
| 26 | 24 | |
@@ -28,8 +26,7 @@ discard block |
||
| 28 | 26 | * @return bool |
| 29 | 27 | * @param string HTTP method |
| 30 | 28 | */ |
| 31 | - public static function isSafeMethod($method) |
|
| 32 | - { |
|
| 29 | + public static function isSafeMethod($method) { |
|
| 33 | 30 | return in_array($method, self::safeMethods()); |
| 34 | 31 | } |
| 35 | 32 | |
@@ -37,16 +34,14 @@ discard block |
||
| 37 | 34 | * @return bool |
| 38 | 35 | * @param string HTTP method |
| 39 | 36 | */ |
| 40 | - public static function isUnsafeMethod($method) |
|
| 41 | - { |
|
| 37 | + public static function isUnsafeMethod($method) { |
|
| 42 | 38 | return !in_array($method, self::safeMethods()); |
| 43 | 39 | } |
| 44 | 40 | |
| 45 | 41 | /** |
| 46 | 42 | * @return array list of (always) idempotent HTTP methods |
| 47 | 43 | */ |
| 48 | - public static function idempotentMethods() |
|
| 49 | - { |
|
| 44 | + public static function idempotentMethods() { |
|
| 50 | 45 | // Though it is possible to be idempotent, POST |
| 51 | 46 | // is not guarunteed to be, and more often than |
| 52 | 47 | // not, it is not. |
@@ -57,8 +52,7 @@ discard block |
||
| 57 | 52 | * @return bool |
| 58 | 53 | * @param string HTTP method |
| 59 | 54 | */ |
| 60 | - public static function isIdempotent($method) |
|
| 61 | - { |
|
| 55 | + public static function isIdempotent($method) { |
|
| 62 | 56 | return in_array($method, self::safeidempotentMethodsMethods()); |
| 63 | 57 | } |
| 64 | 58 | |
@@ -66,8 +60,7 @@ discard block |
||
| 66 | 60 | * @return bool |
| 67 | 61 | * @param string HTTP method |
| 68 | 62 | */ |
| 69 | - public static function isNotIdempotent($method) |
|
| 70 | - { |
|
| 63 | + public static function isNotIdempotent($method) { |
|
| 71 | 64 | return !in_array($method, self::idempotentMethods()); |
| 72 | 65 | } |
| 73 | 66 | |
@@ -78,8 +71,7 @@ discard block |
||
| 78 | 71 | * |
| 79 | 72 | * @return array of HTTP method strings |
| 80 | 73 | */ |
| 81 | - public static function canHaveBody() |
|
| 82 | - { |
|
| 74 | + public static function canHaveBody() { |
|
| 83 | 75 | return array(self::POST, self::PUT, self::PATCH, self::OPTIONS); |
| 84 | 76 | } |
| 85 | 77 | |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | /** |
| 9 | 9 | * Class to organize the Proxy stuff a bit more |
| 10 | 10 | */ |
| 11 | -class Proxy |
|
| 12 | -{ |
|
| 11 | +class Proxy { |
|
| 13 | 12 | const HTTP = CURLPROXY_HTTP; |
| 14 | 13 | const SOCKS4 = CURLPROXY_SOCKS4; |
| 15 | 14 | const SOCKS5 = CURLPROXY_SOCKS5; |