AbstractPlatform::setSettingsTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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 	./Platforms/AbstractPlatform.php
9
 */
10
namespace JaegerApp\Platforms;
11
12
/**
13
 * Jaeger - Platform Abstract
14
 *
15
 * Defines the methods each platform must implement to communicate between themselves
16
 *
17
 * @package Platforms
18
 * @author Eric Lamb <[email protected]>
19
 */
20
abstract class AbstractPlatform
21
{
22
23
    /**
24
     * The base email configuration prototype
25
     * 
26
     * @var array
27
     */
28
    private $email_config = array(
0 ignored issues
show
Unused Code introduced by
The property $email_config is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
        'from_email' => '',
30
        'sender_name' => '',
31
        'type' => 'smtp', // choose between `php` and `smtp`
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
        'smtp_options' => array( // if `smtp` chosen above, this must be completed and accurate
33
            'host' => '',
34
            'connection_config' => array(
35
                'username' => '',
36
                'password' => ''
37
            ),
38
            'port' => ''
39
        )
40
    );
41
    
42
    /**
43
     * The settings table name
44
     * @var string
45
     */
46
    protected $settings_table = '';
47
48
    /**
49
     * Returns an array of details about interacting with the database
50
     */
51
    abstract public function getDbCredentials();
52
53
    /**
54
     * Returns an array of email connection details
55
     * 
56
     * @param array $details            
0 ignored issues
show
Bug introduced by
There is no parameter named $details. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
57
     */
58
    abstract public function getEmailConfig();
59
60
    /**
61
     * Returns the Current URL for the given request
62
     */
63
    abstract public function getCurrentUrl();
64
65
    /**
66
     * Returns the site name
67
     */
68
    abstract public function getSiteName();
69
70
    /**
71
     * Returns the user's timezone
72
     */
73
    abstract public function getTimezone();
74
75
    /**
76
     * Returns the site URL
77
     */
78
    abstract public function getSiteUrl();
79
80
    /**
81
     * Returns the encryption key to use for salting the encrypted data
82
     */
83
    abstract public function getEncryptionKey();
84
85
    /**
86
     * Returns an array of the configuration overrides to use (if any)
87
     */
88
    abstract public function getConfigOverrides();
89
90
    /**
91
     * Platform based abstraction to redirect a user's browser session to a given $url
92
     * 
93
     * @param string $url            
94
     */
95
    abstract public function redirect($url);
96
97
    /**
98
     * Platform based abstraction to handle HTTP get/post request variables
99
     * 
100
     * @param string $key            
101
     * @param string $default            
102
     * @return mixed
103
     */
104
    public function getPost($key, $default = false)
0 ignored issues
show
Coding Style introduced by
getPost uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
getPost uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
105
    {
106
        if (isset($_POST[$key])) {
107
            return $_POST[$key];
108
        } elseif (isset($_GET[$key])) {
109
            return $_GET[$key];
110
        }
111
        
112
        return $default;
113
    }
114
    
115
    /**
116
     * Set the settings table
117
     * @param string $table
118
     * @return \JaegerApp\Platforms\AbstractPlatform
119
     */
120
    public function setSettingsTable($table)
121
    {
122
        $this->settings_table = $table;
123
        return $this;
124
    }
125
    
126
    /**
127
     * Returns the settings table
128
     * @return string
129
     */
130
    public function getSettingsTable()
131
    {
132
        return $this->settings_table;
133
    }
134
}