Completed
Pull Request — master (#431)
by Anton
04:27
created

AbstractTable::getAuthRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Auth;
12
13
use Bluz\Db\Table;
14
15
/**
16
 * Abstract class for Auth\Table
17
 *
18
 * @package  Bluz\Auth
19
 * @author   Anton Shevchuk
20
 *
21
 * @method   static AbstractRow findRow($primaryKey)
22
 * @see      Table::findRow()
23
 *
24
 * @method   static AbstractRow findRowWhere($whereList)
25
 * @see      Table::findRowWhere()
26
 */
27
abstract class AbstractTable extends Table
28
{
29
    /**
30
     * Types
31
     */
32
    const TYPE_ACCESS = 'access';
33
    const TYPE_REQUEST = 'request';
34
35
    /**
36
     * Providers
37
     *  - equals - login+password
38
     *  - token - token with ttl
39
     *  - cookie - cookie token with ttl
40
     */
41
    const PROVIDER_COOKIE = 'cookie';
42
    const PROVIDER_EQUALS = 'equals';
43
    const PROVIDER_FACEBOOK = 'facebook';
44
    const PROVIDER_GOOGLE = 'google';
45
    const PROVIDER_LDAP = 'ldap';
46
    const PROVIDER_TOKEN = 'token';
47
    const PROVIDER_TWITTER = 'twitter';
48
49
    /**
50
     * @var string Table
51
     */
52
    protected $name = 'auth';
53
54
    /**
55
     * @var array Primary key(s)
56
     */
57
    protected $primary = ['provider', 'foreignKey'];
58
59
    /**
60
     * Get AuthRow
61
     *
62
     * @param  string $provider
63
     * @param  string $foreignKey
64
     *
65
     * @return AbstractRow
66
     */
67 1
    public static function getAuthRow($provider, $foreignKey)
68
    {
69 1
        return static::findRow(['provider' => $provider, 'foreignKey' => $foreignKey]);
70
    }
71
}
72