AbstractServer::getHmac()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Jaeger
4
 *
5
 * @copyright	Copyright (c) 2015-2016, mithra62
6
 * @link		http://jaeger-app.com
7
 * @version		1.0
8
 * @filesource 	./Rest/AbstractServer.php
9
 */
10
 
11
namespace JaegerApp\Rest;
12
13
/**
14
 * Abstract REST Server
15
 *
16
 * Sets up and fires off the REST Server
17
 *
18
 * @package Rest
19
 * @author Eric Lamb <[email protected]>
20
 */
21
abstract class AbstractServer
22
{
23
    /**
24
     * The Platform object
25
     * @var \JaegerApp\Platforms\AbstractPlatform
26
     */
27
    protected $platform = null;
28
    
29
    /**
30
     * The REST object
31
     * @var \JaegerApp\Rest
32
     */
33
    protected $rest = null;
34
    
35
    /**
36
     * The API version we're using
37
     * @var string
38
     */
39
    protected $version = null;
40
    
41
    /**
42
     * Set it up
43
     * @param \JaegerApp\Platforms\AbstractPlatform $platform
44
     * @param \JaegerApp\BackupPro\Rest $rest
45
     */
46
    public function __construct(\JaegerApp\Platforms\AbstractPlatform $platform, \JaegerApp\Rest $rest)
47
    {
48
        $this->platform = $platform;
49
        $this->rest = $rest;
50
    }
51
    
52
    /**
53
     * Returns an instance of the Hmac object
54
     * @return \JaegerApp\Rest\Hmac
55
     */
56
    public function getHmac()
57
    {
58
        return new Hmac();
59
    }
60
    
61
    /**
62
     * Creates the version of the API we're expected to use
63
     * @param string $version_key
64
     * @return string
65
     */
66
    public function getVersion($version_key)
67
    {
68
        if(is_null($this->version))
69
        {
70
            //determine the version
71
            $headers = \getallheaders();
72
            if(isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions))
0 ignored issues
show
Bug introduced by
The property api_versions does not seem to exist. Did you mean version?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
73
            {
74
                $version = 'V'.str_replace('.','_',$headers[$version_key]);
75
            }
76
            else
77
            {
78
                $version = 'V1';
79
            }
80
            
81
            $this->version = $version;
82
        }
83
        
84
        return $this->version;
85
    }
86
    
87
    /**
88
     * Outlines the Server routes
89
     * @return void
90
     */
91
    abstract public function run(array $routes = array());
92
}