Completed
Push — v2.0.x ( 7a58b6 )
by Florent
24:58
created

JWEFactory::createJWE()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2015 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
     * JWEFactory constructor.
20
     *
21
     * This factory is not supposed to be instantiated
22
     */
23
    private function __construct() {}
24
25
    /**
26
     * @param mixed                                     $payload
27
     * @param null|string                               $aad
28
     *
29
     * @return \Jose\Object\JWEInterface
30
     */
31
    public static function createJWE($payload, $aad = null)
32
    {
33
        $jwe = new JWE();
34
        $jwe = $jwe->withPayload($payload);
35
36
        if (null !== $aad) {
37
            $jwe = $jwe->withAAD($aad);
38
        }
39
40
        return $jwe;
41
    }
42
}
43