HttpBasicExtension::secureClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
3
namespace Knp\FriendlyContexts\Http\Security;
4
5
use Guzzle\Http\Client;
6
use Guzzle\Http\Message\Request;
7
use Knp\FriendlyContexts\Builder\RequestBuilder;
8
9
/**
10
 * @deprecated use HttpExtension. Will be removed in v1.0.0
11
 */
12
class HttpBasicExtension implements SecurityExtensionInterface
13
{
14
   public function secureClient(Client $client, RequestBuilder $builder)
15
   {
16
   }
17
18 View Code Duplication
    public function secureRequest(Request $request, RequestBuilder $builder)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        $credentials = $builder->getCredentials();
21
22
        if (!isset($credentials['username']) || !isset($credentials['password'])) {
23
            throw new \RuntimeException(
24
                'You must specified a "username" and a "password" for the http basic authentication.'
25
            );
26
        }
27
28
        $request->setAuth($credentials['username'], $credentials['password']);
29
    }
30
}
31