Completed
Push — master ( 7fcbe3...50e2ca )
by Guillaume
23:24
created

AbstractBaseAuthStrategy::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Eljam\GuzzleJwt\Strategy\Auth;
4
5
use Symfony\Component\OptionsResolver\OptionsResolver;
6
7
/**
8
 * @author Guillaume Cavana <[email protected]>
9
 */
10
abstract class AbstractBaseAuthStrategy implements AuthStrategyInterface
11
{
12
    /**
13
     * $options.
14
     *
15
     * @var array
16
     */
17
    protected $options;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param array $options
23
     */
24
    public function __construct(array $options = array())
25
    {
26
        $resolver = new OptionsResolver();
27
        $this->configureOptions($resolver);
28
29
        $this->options = $resolver->resolve($options);
30
    }
31
32
    /**
33
     * configureOptions.
34
     *
35
     * @param OptionsResolver $resolver
36
     */
37
    public function configureOptions(OptionsResolver $resolver)
38
    {
39
        $resolver->setDefaults(array(
40
            'username' => '',
41
            'password' => '',
42
        ));
43
44
        $resolver->setRequired(['username', 'password']);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    abstract public function getRequestOptions();
51
}
52