Completed
Push — master ( 7aad34...96e43e )
by Florent
02:35
created

JWEFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createJWE() 0 13 2
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Factory;
13
14
use Jose\Object\JWE;
15
16
final class JWEFactory
17
{
18
    /**
19
     * @param mixed       $payload
20
     * @param array       $shared_protected_headers
21
     * @param array       $shared_headers
22
     * @param null|string $aad
23
     *
24
     * @return \Jose\Object\JWEInterface
25
     */
26
    public static function createJWE($payload, array $shared_protected_headers = [], array $shared_headers = [], $aad = null)
27
    {
28
        $jwe = new JWE();
29
        $jwe = $jwe->withSharedProtectedHeaders($shared_protected_headers);
30
        $jwe = $jwe->withSharedHeaders($shared_headers);
31
        $jwe = $jwe->withPayload($payload);
32
33
        if (null !== $aad) {
34
            $jwe = $jwe->withAAD($aad);
35
        }
36
37
        return $jwe;
38
    }
39
}
40