Craft::getEncryptionKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Jaeger
4
 *
5
 * @author		Eric Lamb <[email protected]>
6
 * @copyright	Copyright (c) 2015-2016, mithra62, Eric Lamb
7
 * @link		http://jaeger-app.com
8
 * @version		1.0
9
 * @filesource 	./Platforms/Craft.php
10
 */
11
namespace JaegerApp\Platforms;
12
13
use JaegerApp\Platforms\AbstractPlatform;
14
use JaegerApp\Exceptions\PlatformsException;
15
use \CSecurityManager;
16
17
/**
18
 * mithra62 - Craft Platform Object
19
 *
20
 * The bridge between Jaeger code and Craft specific logic
21
 *
22
 * @package Platforms\Craft
23
 * @author Eric Lamb <[email protected]>
24
 */
25
class Craft extends AbstractPlatform
26
{
27
28
    /**
29
     * (non-PHPdoc)
30
     * 
31
     * @see \mithra62\Platforms::getDbCredentials()
32
     */
33
    public function getDbCredentials()
34
    {
35
        $config = \Craft\craft()->config;
36
        if ($config instanceof \Craft\ConfigService) {
0 ignored issues
show
Bug introduced by
The class Craft\ConfigService does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
37
            return array(
38
                'host' => $config->get('server', 'db'),
39
                'port' => $config->get('port', 'db'),
40
                'user' => $config->get('user', 'db'),
41
                'password' => $config->get('password', 'db'),
42
                'database' => $config->get('database', 'db'),
43
                'prefix' => $config->get('tablePrefix', 'db'),
44
                'settings_table_name' => $config->get('tablePrefix', 'db').$this->getSettingsTable()
45
            );
46
        } else {
47
            throw new PlatformsException("\\Craft\\ConfigService object isn't set!");
48
        }
49
    }
50
51
    /**
52
     * (non-PHPdoc)
53
     * 
54
     * @ignore
55
     *
56
     * @see \mithra62\BackupPro\Platforms\PlatformInterface::getEmailConfig()
57
     */
58
    public function getEmailConfig()
59
    {
60
        $email = \Craft\craft()->systemSettings->getSettings('email');
61
        $this->email_config['type'] = $email['protocol'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
62
        $this->email_config['port'] = $email['port'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
63
        if ($email['protocol'] == 'smtp') {
64
            $this->email_config['smtp_options']['host'] = $email['host'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
65
            $this->email_config['smtp_options']['connection_config']['username'] = $email['username'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
66
            $this->email_config['smtp_options']['connection_config']['password'] = $email['password'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
67
        }
68
        
69
        $this->email_config['sender_name'] = $email['senderName'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
70
        $this->email_config['from_email'] = $email['emailAddress'];
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
71
        
72
        return $this->email_config;
0 ignored issues
show
Bug introduced by
The property email_config cannot be accessed from this context as it is declared private in class JaegerApp\Platforms\AbstractPlatform.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
73
    }
74
75
    /**
76
     * (non-PHPdoc)
77
     * 
78
     * @see \mithra62\BackupPro\Platforms\PlatformInterface::getCurrentUrl()
79
     */
80
    public function getCurrentUrl()
81
    {
82
        return \Craft\craft()->request->requestUri;
83
    }
84
85
    /**
86
     * (non-PHPdoc)
87
     * 
88
     * @see \mithra62\Platforms::getSiteName()
89
     */
90
    public function getSiteName()
91
    {
92
        return \Craft\craft()->getInfo('siteName');
93
    }
94
95
    /**
96
     * (non-PHPdoc)
97
     * 
98
     * @see \mithra62\Platforms::getTimezone()
99
     */
100
    public function getTimezone()
101
    {
102
        return \Craft\craft()->getTimezone();
103
    }
104
105
    /**
106
     * (non-PHPdoc)
107
     * 
108
     * @see \mithra62\Platforms\AbstractPlatform::getSiteUrl()
109
     */
110
    public function getSiteUrl()
111
    {
112
        return \Craft\craft()->getInfo('siteUrl');
113
    }
114
115
    /**
116
     * (non-PHPdoc)
117
     * 
118
     * @see \mithra62\Platforms\AbstractPlatform::getEncryptionKey()
119
     */
120
    public function getEncryptionKey()
121
    {
122
        $sec = new CSecurityManager();
123
        return $sec->getEncryptionKey();
124
    }
125
126
    /**
127
     * (non-PHPdoc)
128
     * 
129
     * @see \mithra62\Platforms\AbstractPlatform::getConfigOverrides()
130
     */
131
    public function getConfigOverrides()
132
    {
133
        return array();
134
    }
135
136
    /**
137
     * (non-PHPdoc)
138
     * 
139
     * @see \mithra62\Platforms\AbstractPlatform::redirect()
140
     */
141
    public function redirect($url)
142
    {
143
        // unused
144
    }
145
146
    /**
147
     * (non-PHPdoc)
148
     * 
149
     * @see \mithra62\Platforms\AbstractPlatform::getPost()
150
     */
151
    public function getPost($key, $default = false)
152
    {
153
        return \Craft\craft()->request->getParam($key, $default);
154
    }
155
}