Passed
Push — master ( 90e83d...4a3542 )
by El
03:14
created

lib/Model.php (3 issues)

Checks if used types are declared or listed as dependencies.

Bug Major
1
<?php
2
/**
3
 * PrivateBin
4
 *
5
 * a zero-knowledge paste bin
6
 *
7
 * @link      https://github.com/PrivateBin/PrivateBin
8
 * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
9
 * @license   https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
10
 * @version   1.2
11
 */
12
13
namespace PrivateBin;
14
15
use PrivateBin\Model\Paste;
0 ignored issues
show
The type PrivateBin\Model\Paste 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...
16
use PrivateBin\Persistence\PurgeLimiter;
0 ignored issues
show
The type PrivateBin\Persistence\PurgeLimiter 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...
17
18
/**
19
 * Model
20
 *
21
 * Factory of PrivateBin instance models.
22
 */
23
class Model
24
{
25
    /**
26
     * Configuration.
27
     *
28
     * @var Configuration
29
     */
30
    private $_conf;
31
32
    /**
33
     * Data storage.
34
     *
35
     * @var AbstractData
0 ignored issues
show
The type PrivateBin\AbstractData 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...
36
     */
37
    private $_store = null;
38
39
    /**
40
     * Factory constructor.
41
     *
42
     * @param configuration $conf
43
     */
44 104
    public function __construct(Configuration $conf)
45
    {
46 104
        $this->_conf = $conf;
47 104
    }
48
49
    /**
50
     * Get a paste, optionally a specific instance.
51
     *
52
     * @param string $pasteId
53
     * @return Paste
54
     */
55 86
    public function getPaste($pasteId = null)
56
    {
57 86
        $paste = new Paste($this->_conf, $this->_getStore());
58 86
        if ($pasteId !== null) {
59 56
            $paste->setId($pasteId);
60
        }
61 82
        return $paste;
62
    }
63
64
    /**
65
     * Checks if a purge is necessary and triggers it if yes.
66
     */
67 29
    public function purge()
68
    {
69 29
        PurgeLimiter::setConfiguration($this->_conf);
70 29
        if (PurgeLimiter::canPurge()) {
71 29
            $this->_getStore()->purge($this->_conf->getKey('batchsize', 'purge'));
72
        }
73 29
    }
74
75
    /**
76
     * Gets, and creates if neccessary, a store object
77
     *
78
     * @return AbstractData
79
     */
80 86
    private function _getStore()
81
    {
82 86
        if ($this->_store === null) {
83 86
            $this->_store = forward_static_call(
84 86
                'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model') . '::getInstance',
85 86
                $this->_conf->getSection('model_options')
86
            );
87
        }
88 86
        return $this->_store;
89
    }
90
}
91