Viddler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 36
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 4
A __call() 0 4 1
A call() 0 6 1
1
<?php
2
3
namespace LeadThread\Viddler\Api;
4
5
/**
6
 * Viddler PHP Wrapper for Viddler's API
7
 * Documentation: http://developers.viddler.com
8
 * Version 4.2 (18Jul2014)
9
 */
10
class Viddler
11
{
12
    public $apiKey = null;
13
    public $secure  = false;
14
    protected $requestClass = Request::class;
15
16
    // Constructor
17 9
    public function __construct($apiKey = null, $secure = false)
18
    {
19 9
        $this->apiKey = (! empty($apiKey)) ? $apiKey : $this->apiKey;
20 9
        $this->secure = (! is_null($secure) && is_bool($secure)) ? $secure : $this->secure;
21 9
    }
22
23
    /**
24
     * Can be called like such:
25
     * $__api = new Viddler_API("YOUR KEY");
26
     * $array = $__api->viddler_users_getProfile(array("user"=>"phpfunk"));
27
     */
28 6
    public function __call($method, $args)
29
    {
30 6
        return self::call($method, $args);
31
    }
32
33
    /**
34
     * Format the Method
35
     * Accepted Formats:
36
     *
37
     * $viddler->viddler_users_auth();
38
     */
39 6
    protected function call($method, $args)
40
    {
41 6
        $method = str_replace("_", ".", $method);
42 6
        $request = new $this->requestClass($this->apiKey, $method, $args, $this->secure);
43 6
        return $request->execute();
44
    }
45
}
46