Completed
Push — master ( 72ecff...582962 )
by Damien
11:32
created

SerializeHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A xmlContentType() 0 5 1
A redirectUrl() 0 7 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 */
6
7
namespace flipbox\saml\core\helpers;
8
9
use craft\web\Response;
10
11
class SerializeHelper
12
{
13
14
    /**
15
     * set proper headers to present xml correctly
16
     */
17
    public static function xmlContentType()
18
    {
19
        \Craft::$app->getResponse()->format = Response::FORMAT_RAW;
20
        \Craft::$app->getResponse()->getHeaders()->add('Content-Type', 'text/xml');
21
    }
22
23
    /**
24
     * @param string $location
25
     * @param array $parameters
26
     * @return string
27
     */
28
    public static function redirectUrl(string $location, array $parameters)
29
    {
30
31
        return $location .
32
            (strpos($location, '?') === false ? '?' : '&') .
33
            http_build_query($parameters);
34
    }
35
}
36