Telefonica   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 46
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getVersion() 0 4 1
A findVersion() 0 21 5
1
<?php
2
3
namespace Telefonica;
4
5
use Illuminate\Database\Eloquent\Collection;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Filesystem\Filesystem;
8
use Illuminate\Support\Arr;
9
use Illuminate\Support\Facades\Cache;
10
use Illuminate\Support\Facades\Storage;
11
use Illuminate\Support\Str;
12
use View;
13
use Config;
14
use Request;
15
use Session;
16
use ReflectionClass;
17
18
use Crypto;
19
20
class Telefonica
21
{
22
    protected $version;
23
    protected $filesystem;
24
25
    /**
26
     * The current locale, cached in memory
27
     *
28
     * @var string
29
     */
30
    private $locale;
31
32
    public function __construct()
33
    {
34
        $this->filesystem = app(Filesystem::class);
35
36
        $this->findVersion();
37
    }
38
39
    public function getVersion()
40
    {
41
        return $this->version;
42
    }
43
44
    protected function findVersion()
45
    {
46
        if (!is_null($this->version)) {
47
            return;
48
        }
49
50
        if ($this->filesystem->exists(base_path('composer.lock'))) {
51
            // Get the composer.lock file
52
            $file = json_decode(
53
                $this->filesystem->get(base_path('composer.lock'))
54
            );
55
56
            // Loop through all the packages and get the version of telefonica
57
            foreach ($file->packages as $package) {
58
                if ($package->name == 'sierratecnologia/telefonica') {
59
                    $this->version = $package->version;
60
                    break;
61
                }
62
            }
63
        }
64
    }
65
}
66