Passed
Push — master ( 323542...b3d3d7 )
by Frank
06:59 queued 02:19
created

src/SingleSwitcher.php (3 issues)

Labels
Severity
1
<?php # -*- coding: utf-8 -*-
2
declare(strict_types=1);
3
4
namespace MultisiteGlobalMedia;
5
6
/**
7
 * Class SingleSwitcher
8
 */
9
class SingleSwitcher implements SiteSwitcher
10
{
11
    /**
12
     * @var bool
13
     */
14
    private $switched = false;
15
16
    /**
17
     * Switch to blog if needed
18
     *
19
     * @param int $siteId
20
     */
21
    public function switchToBlog(int $siteId)
22
    {
23
        if (get_current_blog_id() === $siteId) {
0 ignored issues
show
The function get_current_blog_id was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

23
        if (/** @scrutinizer ignore-call */ get_current_blog_id() === $siteId) {
Loading history...
24
            return;
25
        }
26
27
        switch_to_blog($siteId);
0 ignored issues
show
The function switch_to_blog was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

27
        /** @scrutinizer ignore-call */ 
28
        switch_to_blog($siteId);
Loading history...
28
29
        $this->switched = true;
30
    }
31
32
    /**
33
     * Restore the current blog if needed
34
     */
35
    public function restoreBlog()
36
    {
37
        if (!$this->switched) {
38
            return;
39
        }
40
41
        restore_current_blog();
0 ignored issues
show
The function restore_current_blog was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

41
        /** @scrutinizer ignore-call */ 
42
        restore_current_blog();
Loading history...
42
43
        $this->switched = false;
44
    }
45
}
46