Completed
Push — develop ( dbf1eb...cd67db )
by
unknown
13:06
created

SocialButtons::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
namespace Core\View\Helper;
11
12
use Zend\View\Helper\AbstractHelper;
13
use Auth\Options\ModuleOptions;
14
15
class SocialButtons extends AbstractHelper
16
{
17
    /**
18
     * @var ModuleOptions $options;
19
     */
20
    protected $options;
21
22
    /**
23
     * @var array $options;
24
     */
25
    protected $config;
26
27
    /**
28
     * @param $options ModuleOptions
29
     * @param $config array
30
     */
31
    public function __construct($options,$config)
32
    {
33
        $this->options = $options;
34
        $this->config = $config;
35
        return $this;
36
    }
37
38
    /**
39
     * returns the advertised title
40
     *
41
     * @return array
42
     */
43
    public function __invoke()
44
    {
45
        $SocialNetworksEnabled=[];
0 ignored issues
show
Coding Style introduced by
$SocialNetworksEnabled does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
46
        foreach($this->config['hybridauth'] as $key => $val) {
47
            if ($val['enabled'] and in_array(strtolower($key), $this->options->getEnableLogins())){
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
48
                $SocialNetworksEnabled[strtolower($key)] = $key;
0 ignored issues
show
Coding Style introduced by
$SocialNetworksEnabled does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
49
            }
50
        }
51
        return $SocialNetworksEnabled;
0 ignored issues
show
Coding Style introduced by
$SocialNetworksEnabled does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
52
    }
53
}
54