Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Using global is bad practice #1

Open
jerrywham opened this issue Oct 12, 2020 · 0 comments
Open

Using global is bad practice #1

jerrywham opened this issue Oct 12, 2020 · 0 comments

Comments

@jerrywham
Copy link

jerrywham commented Oct 12, 2020

First of all, thank you for this wonderfull and simple app. I love it.

To improve it, I propose you to change global settings for steam and coverart classes to private attribute. It will be more secure and your objects will be more strongs.

So, instead of :

    public function __construct()
    {
        //  get the user's settings
        global $settings;

        //  import the user's settings
        $this->settings = $settings;
       (...)

for the constructor of this two objects, you should used :

    private $settings = array();


    public function __construct(array $settings)
    {

        //  import the user's settings
        $this->settings = $settings;
        (...)

In api/index.php, you have to call these objects with new Steam($settings) and new CoverArt($settings).
And in currentlyPlaying method of CoverArt, new Steam($this->settings) .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant