Permalink
Browse files

Finished cleaning up for PHPCS.

  • Loading branch information...
1 parent feaf8f6 commit c0e01183708e78f4bc8b38e0ca42cd848941fa7d Joe Stump committed Apr 29, 2009
Showing with 69 additions and 16 deletions.
  1. +1 −2 Services/ShortURL/Digg.php
  2. +25 −2 Services/ShortURL/Shortie.php
  3. +14 −0 Services/ShortURL/Trim.php
  4. +6 −5 tests/AllTests.php
  5. +23 −7 tests/Services/ShortURLTest.php
@@ -5,7 +5,7 @@
*
* PHP version 5.2.0+
*
- * LICENSE: This source file is subject to the New BSD license that is
+ * LICENSE: This source file is subject to the New BSD license that is
* available through the world-wide-web at the following URI:
* http://www.opensource.org/licenses/bsd-license.php. If you did not receive
* a copy of the New BSD License and are unable to obtain it through the web,
@@ -49,7 +49,6 @@ class Services_ShortURL_Digg
*/
protected $api = 'http://services.digg.com/url/short';
-
/**
* Constructor
*
@@ -42,8 +42,23 @@ class Services_ShortURL_Shortie
extends Services_ShortURL_Common
implements Services_ShortURL_Interface
{
- private $api = 'http://short.ie/api';
+ /**
+ * Location of API
+ *
+ * @var string $api Location of API
+ */
+ protected $api = 'http://short.ie/api';
+
+ /**
+ * Shorten a URL using {@link http://short.ie}
+ *
+ * @param string $url The URL to shorten
+ *
+ * @throws {@link Services_ShortURL_Exception_CouldNotShorten}
+ * @return string The shortened URL
+ * @see Services_ShortURL_Shortie::sendRequest()
+ */
public function shorten($url)
{
$params = array(
@@ -68,7 +83,15 @@ public function shorten($url)
return (string)$xml->shortened;
}
- private function sendRequest($url)
+ /**
+ * Send a request to {@link http://short.ie}
+ *
+ * @param string $url The URL to send the request to
+ *
+ * @throws {@link Services_ShortURL_Exception_CouldNotShorten}
+ * @return object Instance of SimpleXMLElement
+ */
+ protected function sendRequest($url)
{
$this->req->setUrl($url);
$this->req->setMethod('GET');
View
@@ -41,8 +41,22 @@ class Services_ShortURL_Trim
extends Services_ShortURL_Common
implements Services_ShortURL_Interface
{
+ /**
+ * Location of API
+ *
+ * @var string $api Location of API
+ */
protected $api = 'http://api.tr.im/api/trim_url.xml';
+ /**
+ * Shorten a URL using {@link http://tr.im}
+ *
+ * @param string $url The URL to shorten
+ *
+ * @throws {@link Services_ShortURL_Exception_CouldNotShorten}
+ * @return string The shortened URL
+ * @see Services_ShortURL_Digg::sendRequest()
+ */
public function shorten($url)
{
$url = $this->api . '?url=' . $url;
View
@@ -5,7 +5,7 @@
*
* PHP version 5.2.0+
*
- * LICENSE: This source file is subject to the New BSD license that is
+ * LICENSE: This source file is subject to the New BSD license that is
* available through the world-wide-web at the following URI:
* http://www.opensource.org/licenses/bsd-license.php. If you did not receive
* a copy of the New BSD License and are unable to obtain it through the web,
@@ -29,10 +29,11 @@
/**
* The all tests suite file
*
- * @category Services
- * @package Services_ShortURL
- * @author Joe Stump <joe@joestump.net>
- * @link http://api.tr.im/website/api
+ * @category Services
+ * @package Services_ShortURL
+ * @author Joe Stump <joe@joestump.net>
+ * @license http://tinyurl.com/new-bsd New BSD License
+ * @link http://api.tr.im/website/api
*/
class Services_ShortURL_AllTests
{
@@ -5,7 +5,7 @@
*
* PHP version 5.2.0+
*
- * LICENSE: This source file is subject to the New BSD license that is
+ * LICENSE: This source file is subject to the New BSD license that is
* available through the world-wide-web at the following URI:
* http://www.opensource.org/licenses/bsd-license.php. If you did not receive
* a copy of the New BSD License and are unable to obtain it through the web,
@@ -28,10 +28,11 @@
/**
* Basic test cases that shorten/expand
*
- * @category Services
- * @package Services_ShortURL
- * @author Joe Stump <joe@joestump.net>
- * @link http://api.tr.im/website/api
+ * @category Services
+ * @package Services_ShortURL
+ * @author Joe Stump <joe@joestump.net>
+ * @license http://tinyurl.com/new-bsd New BSD License
+ * @link http://api.tr.im/website/api
*/
class Services_ShortURLTest extends PHPUnit_Framework_TestCase
{
@@ -80,12 +81,14 @@ public function setUp()
/**
* Test creating and then expanding a URL
*
+ * @param string $service The service to test
+ *
* @dataProvider allServices
* @return void
*/
public function testCreateThenExpand($service)
{
- $api = Services_ShortURL::factory($service);
+ $api = Services_ShortURL::factory($service);
// Create a short URL and do some sanity checking
$small = $api->shorten($this->testURL);
@@ -108,7 +111,7 @@ public function testCreateThenExpand($service)
*/
public function testDetect($url, $service)
{
- $api = Services_ShortURL::detect($url);
+ $api = Services_ShortURL::detect($url);
$expected = 'Services_ShortURL_' . $service;
$this->assertType($expected, $api);
@@ -117,7 +120,10 @@ public function testDetect($url, $service)
}
/**
+ * Test extraction function
*
+ * @see Services_ShortURLTest::detectServices()
+ * @return void
*/
public function testExtract()
{
@@ -139,6 +145,11 @@ public function testExtract()
}
}
+ /**
+ * Return all services
+ *
+ * @return array List of services
+ */
public function allServices()
{
return array(
@@ -151,6 +162,11 @@ public function allServices()
);
}
+ /**
+ * Return example URLs + service name
+ *
+ * @return array List of services with URLs
+ */
public function detectServices()
{
return array(

0 comments on commit c0e0118

Please sign in to comment.