TumblrController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getBlogInfo() 0 6 1
A getPosts() 0 6 1
A getPage() 0 6 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Tumblr;
6
use App\Http\Requests;
7
8
class TumblrController extends Controller
9
{
10
    /**
11
     * Instance of Tumblr API
12
     * @var object
13
     */
14
    protected $tumblr;
15
16
     /**
17
     * Initialize the Controller with necessary arguments
18
     */
19
    public function __construct()
20
    {
21
        $this->tumblr = new Tumblr();
22
23
        // Set API key.
24
        $this->tumblr->setApiKey(env('TUMBLR_API_KEY'));
25
    }
26
27
    /**
28
     * Get Basic Information about the blog
29
     * @return array
30
     */
31
    private function getBlogInfo($tumblrBlogUrl)
32
    {
33
        $info = $this->tumblr->blogInfo($tumblrBlogUrl);
34
35
        return (array)$info;
36
    }
37
38
    /**
39
     * Get Posts from the Tumblr blog
40
     * @return array
41
     */
42
    private function getPosts($tumblrBlogUrl)
43
    {
44
        $info = $this->tumblr->posts($tumblrBlogUrl);
45
46
        return (array)$info->response->posts;
47
    }
48
49
    /**
50
     * Return all data to the Tumblr API dashboard
51
     * @return mixed
52
     */
53
    public function getPage()
54
    {
55
        $posts = $this->getPosts('taylorswift.tumblr.com');
56
57
        return view('api.tumblr')->withPosts($posts);
58
    }
59
}
60