Skip to content

Commit

Permalink
Added Namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinrafiei committed Jan 3, 2019
1 parent 6e89293 commit 063addd
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 476 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea
/vendor/
14 changes: 0 additions & 14 deletions .idea/deployment.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/easy-yelp.iml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/php.xml

This file was deleted.

389 changes: 0 additions & 389 deletions .idea/workspace.xml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require 'yelp.php';
If you're using composer or autoloader then you don't need to include it manually. You just need to configure your autoloader tool.

```php
$yelp = new Yelp('YOUR_TOKEN');
$yelp = new EasyYelp\Yelp('YOUR_API_TOKEN');
$businesses = $yelp->businessSearch([
'location' => 'Los Angeles, CA',
'price' => '1,2,3',
Expand Down Expand Up @@ -89,6 +89,9 @@ $alias = 'blahblah';
$request = [];
$yelp->categoryDetails($alias, $request)->getArray();
```
### Examples
You can check tests directory files to see some examples for using API methods.

### Errors
To check if you received an error from Yelp API or not you can use following functions.
```php
Expand Down
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "hoseinrafiei/easy-yelp",
"description": "A light-weight PHP Client for Yelp Fusion API",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Hosein Rafiei",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0.0"
},
"autoload": {
"psr-0": {
"HoseinRafiei": "src/"
}
}
}
54 changes: 28 additions & 26 deletions src/yelp.php → src/EasyYelp/yelp.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php
namespace EasyYelp;

/**
* Yelp API Client
*
* @author Hossein R. <[email protected]>
* @class Yelp
* @author Hosein Rafiei <[email protected]>
* @class EasyYelp
* @version 1.0.0
*/
class Yelp
Expand All @@ -27,7 +29,7 @@ class Yelp
private $token;

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $token
*/
public function __construct(string $token)
Expand All @@ -36,7 +38,7 @@ public function __construct(string $token)
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -46,7 +48,7 @@ public function businessSearch(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -56,7 +58,7 @@ public function businessPhoneSearch(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $transactionType
* @param array $args
* @return Yelp
Expand All @@ -67,7 +69,7 @@ public function transactionSearch(string $transactionType = 'delivery', array $a
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $id
* @param array $args
* @return Yelp
Expand All @@ -78,7 +80,7 @@ public function businessDetails(string $id, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -88,7 +90,7 @@ public function businessMatch(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $id
* @param array $args
* @return Yelp
Expand All @@ -99,7 +101,7 @@ public function businessReviews(string $id, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -109,7 +111,7 @@ public function autocomplete(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -119,7 +121,7 @@ public function events(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $id
* @param array $args
* @return Yelp
Expand All @@ -130,7 +132,7 @@ public function eventDetails(string $id, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -140,7 +142,7 @@ public function featuredEvent(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param array $args
* @return Yelp
*/
Expand All @@ -150,7 +152,7 @@ public function categories(array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $alias
* @param array $args
* @return Yelp
Expand All @@ -161,7 +163,7 @@ public function categoryDetails(string $alias, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @return array
*/
public function getArray()
Expand All @@ -170,7 +172,7 @@ public function getArray()
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @return array
*/
public function getObject()
Expand All @@ -179,8 +181,8 @@ public function getObject()
}

/**
* @author Hossein R. <[email protected]>
* @param array|stdClass $response
* @author Hosein Rafiei <[email protected]>
* @param array|\stdClass $response
* @return boolean
*/
public function hasError($response = NULL)
Expand All @@ -194,8 +196,8 @@ public function hasError($response = NULL)
}

/**
* @author Hossein R. <[email protected]>
* @param array|stdClass $response
* @author Hosein Rafiei <[email protected]>
* @param array|\stdClass $response
* @return string
*/
public function getError($response = NULL)
Expand All @@ -212,7 +214,7 @@ public function getError($response = NULL)
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $route
* @param array $args
* @return Yelp
Expand All @@ -223,7 +225,7 @@ protected function _postRequest(string $route, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $route
* @param array $args
* @return Yelp
Expand All @@ -234,7 +236,7 @@ protected function _getRequest(string $route, array $args = array())
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $route
* @param array $args
* @param string $method
Expand Down Expand Up @@ -283,7 +285,7 @@ protected function _call(string $route, array $args = array(), string $method =
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @param string $route
* @return string
*/
Expand All @@ -293,7 +295,7 @@ protected function _url(string $route)
}

/**
* @author Hossein R. <[email protected]>
* @author Hosein Rafiei <[email protected]>
* @return string
*/
protected function _getTokenHeader()
Expand Down
4 changes: 2 additions & 2 deletions tests/business-details.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Yelp Client
require '../src/yelp.php';
require '../src/EasyYelp/yelp.php';

// Telp Token
$token = 'PUT_YOUR_TOKEN_HERE';

// Yelp Instance
$yelp = new Yelp($token);
$yelp = new EasyYelp\Yelp($token);

// Get Yelp Businesses
$businessId = 'gLn9MKqseb1leWZOWqD54g';
Expand Down
4 changes: 2 additions & 2 deletions tests/business-reviews.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Yelp Client
require '../src/yelp.php';
require '../src/EasyYelp/yelp.php';

// Telp Token
$token = 'PUT_YOUR_TOKEN_HERE';

// Yelp Instance
$yelp = new Yelp($token);
$yelp = new EasyYelp\Yelp($token);

// Get Yelp Businesses
$businessId = 'gLn9MKqseb1leWZOWqD54g';
Expand Down
4 changes: 2 additions & 2 deletions tests/business-search.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Yelp Client
require '../src/yelp.php';
require '../src/EasyYelp/yelp.php';

// Telp Token
$token = 'PUT_YOUR_TOKEN_HERE';

// Yelp Instance
$yelp = new Yelp($token);
$yelp = new EasyYelp\Yelp($token);

// Get Yelp Businesses
$request = [
Expand Down
4 changes: 2 additions & 2 deletions tests/get-categories.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Yelp Client
require '../src/yelp.php';
require '../src/EasyYelp/yelp.php';

// Telp Token
$token = 'PUT_YOUR_TOKEN_HERE';

// Yelp Instance
$yelp = new Yelp($token);
$yelp = new EasyYelp\Yelp($token);

// Get Yelp Categories
$response = $yelp->categories()->getArray();
Expand Down
4 changes: 2 additions & 2 deletions tests/get-category-details.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
// Yelp Client
require '../src/yelp.php';
require '../src/EasyYelp/yelp.php';

// Telp Token
$token = 'PUT_YOUR_TOKEN_HERE';

// Yelp Instance
$yelp = new Yelp($token);
$yelp = new EasyYelp\Yelp($token);

// Get Yelp Categories
$response = $yelp->categories()->getArray();
Expand Down
Loading

0 comments on commit 063addd

Please sign in to comment.