Completed
Push — develop ( 78995e...bfd409 )
by Risan Bagja
01:42
created

OAuth1Factory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Risan\OAuth1;
4
5
use Risan\OAuth1\Request\UriParser;
6
use Risan\OAuth1\Config\ConfigFactory;
7
use Risan\OAuth1\Request\NonceGenerator;
8
use Risan\OAuth1\Request\RequestFactory;
9
use Risan\OAuth1\Signature\HmacSha1Signer;
10
use Risan\OAuth1\Request\ProtocolParameter;
11
use Risan\OAuth1\Request\AuthorizationHeader;
12
use Risan\OAuth1\Credentials\CredentialsFactory;
13
14
class OAuth1Factory
15
{
16
    /**
17
     * Create the new OAuth1Interface instance.
18
     *
19
     * @param  array  $config
20
     * @return \Risan\OAuth1\OAuth1Interface
21
     */
22 1
    public static function create(array $config)
23
    {
24 1
        $configFactory = new ConfigFactory;
25
26 1
        $protocolParameter = new ProtocolParameter(
27 1
            $configFactory->createFromArray($config),
28 1
            new HmacSha1Signer,
29 1
            new NonceGenerator
30
        );
31
32 1
        $authorizationHeader = new AuthorizationHeader($protocolParameter);
33
34 1
        $requestFactory = new RequestFactory($authorizationHeader, new UriParser);
35
36 1
        return new OAuth1(new HttpClient, $requestFactory, new CredentialsFactory);
37
    }
38
}
39