Issues (22)

examples/Store.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Examples\Models;
4
5
/**
6
 * Class Store
7
 * @package Examples\Models
8
 *
9
 * This class represents who you may store the lifeboat store information
10
 * that is returned from the auth service.
11
 *
12
 * This information will allow you to make additional requests to the
13
 * Lifeboat API without the need to ask for user interaction.
14
 *
15
 * This model assumes that it exists in a database table
16
 * containing the following columns:
17
 * - CHAR(16) SiteKey (16 alphanumeric characters)
18
 * - VARCHAR SiteHost
19
 */
20
class Store extends Object {
0 ignored issues
show
The type Examples\Models\Object was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
    // These parameters should reflect table columns in a database
23
    private $SiteKey    = '';
24
    private $SiteHost   = '';
25
26
    public function getSiteKey(): string
27
    {
28
        return $this->SiteKey;
29
    }
30
31
    public function getSiteHost(): string
32
    {
33
        return $this->SiteHost;
34
    }
35
36
    public static function find_or_make(string $site_key, string $host = ''): Store
37
    {
38
        // Perform whatever logic is necessary to find the object in your DB
39
        $find = self::get()->find('SiteKey', $site_key);
40
        if (!$find) {
41
            $find = new self();
42
            $find->SiteKey = $site_key;
43
        }
44
45
        // Always check if the host has changed.
46
        // Users may change their master domain and thus changing the host
47
        if ($host && $host !== $find->SiteHost) {
48
            $find->SiteHost = $host;
49
        }
50
51
        // Write any changes to the database
52
        $find->save();
53
54
        // Return this object
55
        return $find;
56
    }
57
}
58