Completed
Push — v2.0.x ( 2b2b8e...21aa40 )
by Florent
03:32
created

JWEFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
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