Issues (8)

src/Storage.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Alex19pov31\LinkedData;
4
5
class Storage implements StorgeInterface
6
{
7
    /**
8
     * Список репозиториев
9
     *
10
     * @var array|null
11
     */
12
    private static $data;
13
14
    /**
15
     * Возвращает репозиторий по названию
16
     *
17
     * @param string $name
18
     * @return RepositoryInterface|null
19
     */
20
    public static function getRepository(string $name)
21
    {
22
        if (!isset(static::$data[$name])) {
0 ignored issues
show
Since $data is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $data to at least protected.
Loading history...
23
            return static::$data[$name] = new BaseRepository($name);
24
        }
25
26
        return static::$data[$name];
27
    }
28
29
    /**
30
     * Сохранить данные репозиториев в кеш
31
     *
32
     * @param integer $minutes
33
     * @return void
34
     */
35
    public static function saveToCache(int $minutes)
36
    {
37
        if (is_null(static::$data)) {
0 ignored issues
show
Since $data is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $data to at least protected.
Loading history...
38
            return;
39
        }
40
41
        foreach (static::$data as $repository) {
42
            $repository->updateCache($minutes);
43
        }
44
    }
45
}
46