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.

Intl::usingLocale()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 3
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 2
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace RafaHernandez\LaravelIntl\Contracts;
4
5
use Illuminate\Support\Traits\Macroable;
6
7
abstract class Intl
8
{
9
    use Macroable;
10
11
    /**
12
     * Get the current locale.
13
     *
14
     * @return string
15
     */
16
    abstract public function getLocale();
17
18
    /**
19
     * Set the current locale.
20
     *
21
     * @param $locale
22
     * @return $this
23
     */
24
    abstract public function setLocale($locale);
25
26
    /**
27
     * Get the fallback locale.
28
     *
29
     * @return string
30
     */
31
    abstract public function getFallbackLocale();
32
33
    /**
34
     * Set the fallback locale.
35
     *
36
     * @param $locale
37
     * @return $this
38
     */
39
    abstract public function setFallbackLocale($locale);
40
41
    /**
42
     * Run the given callable while using another locale.
43
     *
44
     * @param string $locale
45
     * @param callable $callback
46
     * @param string|null $fallbackLocale
47
     * @return mixed
48
     */
49 12
    public function usingLocale($locale, callable $callback, $fallbackLocale = null)
50
    {
51 12
        $originalLocale = $this->getLocale();
52 12
        $originalFallbackLocale = $this->getFallbackLocale();
53
54 12
        $this->setLocale($locale);
55 12
        $this->setFallbackLocale($fallbackLocale ?: $originalFallbackLocale);
56
57 12
        $result = $callback($this);
58
59 12
        $this->setFallbackLocale($originalFallbackLocale);
60 12
        $this->setLocale($originalLocale);
61
62 12
        return $result;
63
    }
64
}
65