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

JWSFactory::createJWS()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
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 Base64Url\Base64Url;
15
use Jose\Object\JWS;
16
17
final class JWSFactory
18
{
19
    /**
20
     * @param mixed $payload
21
     *
22
     * @return \Jose\Object\JWSInterface
23
     */
24
    public static function createJWS($payload)
25
    {
26
        $jws = new JWS();
27
        $jws = $jws->withPayload($payload);
28
29
        return $jws;
30
    }
31
32
    /**
33
     * @param mixed  $payload
34
     * @param string $encoded_payload
35
     *
36
     * @return \Jose\Object\JWSInterface
37
     */
38
    public static function createJWSWithDetachedPayload($payload, &$encoded_payload)
39
    {
40
        $encoded_payload = Base64Url::encode(is_string($payload) ? $payload : json_encode($payload));
41
42
        return new JWS();
43
    }
44
}
45