Completed
Push — develop ( d888c9...6e2421 )
by
unknown
09:16
created

AbstractAdapter::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** AbstractProfile.php */
11
namespace Auth\Controller\Plugin\SocialProfiles;
12
13
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
14
use Hybrid_Provider_Adapter;
15
16
abstract class AbstractAdapter extends AbstractPlugin
17
{
18
    
19
    public function __invoke($api)
20
    {
21
        return $this->fetch($api);
22
    }
23
    
24
    /**
25
     * @param mixed $api
26
     * @param Hybrid_Provider_Adapter $hauthAdapter
27
     */
28
    public function init($api, Hybrid_Provider_Adapter $hauthAdapter)
29
    {}
30
    
31
    /**
32
     * @param string $network
0 ignored issues
show
Bug introduced by
There is no parameter named $network. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
33
     * @return \Auth\Entity\SocialProfiles\ProfileInterface|bool
0 ignored issues
show
Documentation introduced by
Should the return type not be false|object?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
34
     */
35
    public function fetch($api)
36
    {
37
        $result  = $this->queryApi($api);
38
        if (!$result) {
39
            return false;
40
        }
41
        
42
        $profile = $this->getProfile();
43
        $profile->setData($result);
44
                
45
        return $profile;
46
    }
47
    
48
    abstract protected function queryApi($api);
49
    
50
    protected function getProfile()
51
    {
52
        $class   = $this->getProfileClass();
53
        $profile = new $class();
54
        
55
        return $profile;
56
    }
57
    
58
    protected function getProfileClass()
59
    {
60
        $class = get_class($this);
61
        $class = explode('\\', $class);
62
        $class = array_pop($class);
63
        $class = '\\Auth\\Entity\\SocialProfiles\\' . $class;
64
        
65
        return $class;
66
    }
67
}
68