FoursquareController::getVenues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use FoursquareApi;
6
use App\Http\Requests;
7
8
class FoursquareController extends Controller
9
{
10
    /**
11
     * Instance of Foursquare API
12
     * @var object
13
     */
14
    protected $foursquare;
15
16
     /**
17
     * Initialize the Controller with necessary arguments
18
     */
19
    public function __construct()
20
    {
21
        $this->foursquare = new FoursquareApi(env('FOURSQUARE_CLIENT_ID'), env('FOURSQUARE_CLIENT_SECRET'));
22
    }
23
24
    /**
25
     * Search For Venues
26
     * @return array
27
     */
28
    private function getVenues()
29
    {
30
        // Searching for venues nearby e.g Lagos, Nigeria
31
        $endpoint = 'venues/search';
32
33
        // Prepare parameters
34
        $params = ['near' => 'Lagos, Nigeria'];
35
36
        // Perform a request to a public resource
37
        $response = json_decode($this->foursquare->GetPublic($endpoint,$params),true);
38
39
        return $response['response']['venues'];
40
    }
41
42
    /**
43
     * Return all data to the Foursquare API dashboard
44
     * @return mixed
45
     */
46
    public function getPage()
47
    {
48
        $venues = $this->getVenues();
49
50
        return view('api.foursquare')->withVenues($venues);
51
    }
52
53
}
54