Passed
Push — master ( aba784...c39888 )
by Andre
09:06 queued 11s
created

SocializerVariable::validateAppleSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Socializer plugin for Craft CMS 3.x
4
 *
5
 * @link      https://enupal.com/
6
 * @copyright Copyright (c) 2019 Enupal LLC
7
 */
8
9
namespace enupal\socializer\variables;
10
11
use enupal\socializer\elements\db\ProvidersQuery;
12
use enupal\socializer\elements\Provider;
13
use Craft;
14
use enupal\socializer\Socializer;
15
use yii\base\Behavior;
16
17
/**
18
 * Socializer provides an API for accessing information about providers. It is accessible from templates via `craft.socializer`.
19
 *
20
 */
21
class SocializerVariable extends Behavior
22
{
23
    /**
24
     * @var Provider
25
     */
26
    public $providers;
27
28
    /**
29
     * Returns a new OrderQuery instance.
30
     *
31
     * @param mixed $criteria
32
     * @return ProvidersQuery
33
     */
34
    public function providers($criteria = null): ProvidersQuery
35
    {
36
        $query = Provider::find();
37
        if ($criteria) {
38
            Craft::configure($query, $criteria);
39
        }
40
        return $query;
41
    }
42
43
    /**
44
     * @param string $handle
45
     * @return array|Provider|null
46
     */
47
    public function getProviderByHandle(string $handle)
48
    {
49
        return Socializer::$app->providers->getProviderByHandle($handle);
50
    }
51
52
    /**
53
     * @return array
54
     * @throws \ReflectionException
55
     */
56
    public function getProvidersAsOptions()
57
    {
58
        return Socializer::$app->providers->getProviderTypesAsOptions();
59
    }
60
61
    /**
62
     * @return bool|\craft\base\Model|null
63
     */
64
    public function getSettings()
65
    {
66
        return Socializer::getInstance()->getSettings();
67
    }
68
69
    /**
70
     * @return \enupal\socializer\services\App
71
     */
72
    public function app()
73
    {
74
        return Socializer::$app;
75
    }
76
77
    /**
78
     * @param $handle
79
     * @param $options
80
     * @return string
81
     * @throws \yii\base\Exception
82
     * @throws \yii\base\NotSupportedException
83
     */
84
    public function loginUrl($handle, $options = [])
85
    {
86
        return Socializer::$app->providers->loginUrl($handle, $options);
87
    }
88
89
    public function validateAppleSettings()
90
    {
91
        return Socializer::$app->settings->validateAppleSettings();
92
    }
93
}