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

FormAuthStrategy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 10 1
A getRequestOptions() 0 9 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
class FormAuthStrategy extends AbstractBaseAuthStrategy
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function configureOptions(OptionsResolver $resolver)
16
    {
17
        parent::configureOptions($resolver);
18
19
        $resolver->setDefaults([
20
            'form_fields' => ['_username', '_password'],
21
        ]);
22
23
        $resolver->setRequired(['form_fields']);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getRequestOptions()
30
    {
31
        return [
32
            \GuzzleHttp\RequestOptions::FORM_PARAMS => [
33
                $this->options['form_fields'][0] => $this->options['username'],
34
                $this->options['form_fields'][1] => $this->options['password'],
35
            ],
36
        ];
37
    }
38
}
39