GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (389)

Branch: master

src/Wysiwyg/Manager.php (4 issues)

1
<?php
2
3
namespace SleepingOwl\Admin\Wysiwyg;
4
5
use Illuminate\Config\Repository;
6
use Illuminate\Contracts\Foundation\Application;
7
use Illuminate\Support\Collection;
8
use SleepingOwl\Admin\Contracts\Wysiwyg\WysiwygEditorInterface;
9
use SleepingOwl\Admin\Contracts\Wysiwyg\WysiwygFilterInterface;
10
use SleepingOwl\Admin\Contracts\Wysiwyg\WysiwygMangerInterface;
11
use SleepingOwl\Admin\Exceptions\WysiwygException;
12
13
class Manager implements WysiwygMangerInterface
14
{
15
    /**
16
     * @var
17
     */
18
    protected $config;
19
20
    /**
21
     * Available wysiwyg editors.
22
     *
23
     * @var Collection|WysiwygEditorInterface[]
24
     */
25
    protected $filters;
26
27
    /**
28
     * @var Application
29
     */
30
    protected $app;
31
32
    /**
33
     * Manager constructor.
34
     *
35
     * @param Application $application
36
     */
37 285
    public function __construct(Application $application)
38
    {
39 285
        $this->filters = new Collection();
40 285
        $this->app = $application;
41
42 285
        $this->config = new Repository(
43 285
            $this->app['config']->get('sleeping_owl.wysiwyg', [])
44 285
        );
45 285
    }
46
47
    /**
48
     * @return string|null
49
     */
50
    public function getDefaultEditorId()
51
    {
52
        return $this->config->get('default', 'ckeditor');
53
    }
54
55
    /**
56
     * @param string $editorId
57
     * @param WysiwygFilterInterface|null $filter
58
     * @param string|null $name
59
     *
60
     * @return WysiwygEditorInterface
61
     */
62 285
    public function register($editorId, WysiwygFilterInterface $filter = null, $name = null)
63
    {
64 285
        $this->getFilters()->push(
65 285
            $editor = new Editor($editorId, $name, $filter, $this->config->get($editorId, []))
66 285
        );
67
68 285
        return $editor;
69
    }
70
71
    /**
72
     * @return Collection|WysiwygEditorInterface[]
73
     */
74 285
    public function getFilters()
75
    {
76 285
        return $this->filters;
77
    }
78
79
    /**
80
     * @param string $editorId
81
     *
82
     * @return WysiwygEditorInterface|null
83
     */
84
    public function getEditor($editorId)
85
    {
86
        return $this->getFilters()->filter(function (WysiwygEditorInterface $editor) use ($editorId) {
87
            return $editor->getId() == $editorId;
88
        })->first();
89
    }
90
91
    public function loadDefaultEditor()
92
    {
93
        $this->loadEditor($this->getDefaultEditor());
0 ignored issues
show
$this->getDefaultEditor() of type SleepingOwl\Admin\Contra...\WysiwygEditorInterface is incompatible with the type string expected by parameter $editorId of SleepingOwl\Admin\Wysiwyg\Manager::loadEditor(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

93
        $this->loadEditor(/** @scrutinizer ignore-type */ $this->getDefaultEditor());
Loading history...
94
    }
95
96
    /**
97
     * @param string $editorId
98
     *
99
     * @return bool
100
     */
101
    public function loadEditor($editorId)
102
    {
103
        if (! is_null($editor = $this->getEditor($editorId))) {
104
            if ($editor->isUsed()) {
105
                return true;
106
            }
107
108
            return $editor->load();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $editor->load() returns the type void which is incompatible with the documented return type boolean.
Loading history...
Are you sure the usage of $editor->load() targeting SleepingOwl\Admin\Contra...EditorInterface::load() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
109
        }
110
111
        return false;
112
    }
113
114
    /**
115
     * @param string $editorId
116
     * @param string $text
117
     *
118
     * @return string string
119
     * @throws WysiwygException
120
     */
121
    public function applyFilter($editorId, $text)
122
    {
123
        if (! is_null($editor = $this->getEditor($editorId))) {
124
            return $editor->applyFilter($text);
125
        }
126
127
        throw new WysiwygException("Editor [{$editorId}] not found");
128
    }
129
130
    /**
131
     * @return array
132
     */
133
    public function getFiltersList()
134
    {
135
        return $this->getFilters()->pluck('name', 'id')->all();
136
    }
137
138
    /**
139
     * @return WysiwygEditorInterface
140
     */
141
    protected function getDefaultEditor()
142
    {
143
        return $this->getEditor($this->getDefaultEditor());
0 ignored issues
show
$this->getDefaultEditor() of type SleepingOwl\Admin\Contra...\WysiwygEditorInterface is incompatible with the type string expected by parameter $editorId of SleepingOwl\Admin\Wysiwyg\Manager::getEditor(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

143
        return $this->getEditor(/** @scrutinizer ignore-type */ $this->getDefaultEditor());
Loading history...
144
    }
145
}
146