Passed
Push — dev ( 451d27...7f1499 )
by Someshwer
02:53
created

DataRepository   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 149
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 149
ccs 0
cts 58
cp 0
rs 10
c 0
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A cities() 0 5 1
A oceans() 0 5 1
A countries() 0 5 1
A unionTerritories() 0 5 1
A countriesHelper() 0 5 1
A wonders() 0 5 1
A timezones() 0 4 1
A continents() 0 5 1
A currencies() 0 5 1
A countriesISOData() 0 5 1
A stdCodes() 0 5 1
A states() 0 5 1
1
<?php
2
3
namespace Someshwer\WorldCountries\Data;
4
5
use DateTimeZone;
6
use Illuminate\Support\Facades\File;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\File 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...
7
8
/**
9
 * Author: Someshwer Bandapally
10
 * Date: 25-05-2018.
11
 *
12
 * This class contains all the data that need
13
 * to be returned up on the request.
14
 *
15
 * Class DataRepository
16
 */
17
class DataRepository
18
{
19
    /**
20
     * Path to data files.
21
     *
22
     * @var string
23
     */
24
    private $base_path = __DIR__.'/../Res/';
25
26
    /**
27
     * This method contains countries data
28
     * such as all country names.
29
     *
30
     * @return array
31
     */
32
    public function countries()
33
    {
34
        $path = $this->base_path.'country_names.txt';
35
36
        return File::get($path);
37
    }
38
39
    /**
40
     * This method reads country ISO  data from a file.
41
     *
42
     * @return mixed
43
     */
44
    public function countriesISOData()
45
    {
46
        $path = $this->base_path.'country_iso.txt';
47
48
        return File::get($path);
49
    }
50
51
    /**
52
     * This method reads the continents data from a file.
53
     *
54
     * @return mixed
55
     */
56
    public function continents()
57
    {
58
        $path = $path = $this->base_path.'continents.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
59
60
        return File::get($path);
61
    }
62
63
    /**
64
     * Reading oceans data from a file.
65
     *
66
     * @return mixed
67
     */
68
    public function oceans()
69
    {
70
        $path = $path = $this->base_path.'oceans.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
71
72
        return File::get($path);
73
    }
74
75
    /**
76
     * Reading union territories data from a file.
77
     *
78
     * @return mixed
79
     */
80
    public function unionTerritories()
81
    {
82
        $path = $path = $this->base_path.'territories.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
83
84
        return File::get($path);
85
    }
86
87
    /**
88
     * Reading wonders data from a file.
89
     *
90
     * @return mixed
91
     */
92
    public function wonders()
93
    {
94
        $path = $path = $this->base_path.'wonders.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
95
96
        return File::get($path);
97
    }
98
99
    /**
100
     * Reading all timezones from predefined php library.
101
     *
102
     * timezone_identifiers_list() is also returns same list of timezones.
103
     * It is just an alias for 'DateTimeZone::listIdentifiers(DateTimeZone::ALL)'
104
     *
105
     * @return array
106
     */
107
    public function timezones()
108
    {
109
        // timezone_identifiers_list() is also returns same list of timezones.
110
        return DateTimeZone::listIdentifiers(DateTimeZone::ALL);
111
    }
112
113
    /**
114
     * Reading all currencies from a text file.
115
     *
116
     * @return mixed
117
     */
118
    public function currencies()
119
    {
120
        $path = $path = $this->base_path.'currencies.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
121
122
        return File::get($path);
123
    }
124
125
    /**
126
     * Reading all std codes from a text file.
127
     *
128
     * @return mixed
129
     */
130
    public function stdCodes()
131
    {
132
        $path = $path = $this->base_path.'std_codes.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
133
134
        return File::get($path);
135
    }
136
137
    /**
138
     * Reading all states from a text file.
139
     *
140
     * @return mixed
141
     */
142
    public function states()
143
    {
144
        $path = $path = $this->base_path.'states.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
145
146
        return File::get($path);
147
    }
148
149
    /**
150
     * Reading all countries from countries helper for states.
151
     *
152
     * @return mixed
153
     */
154
    public function countriesHelper()
155
    {
156
        $path = $path = $this->base_path.'countries_helper.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
157
158
        return File::get($path);
159
    }
160
161
    public function cities()
162
    {
163
        $path = $path = $this->base_path.'cities.txt';
0 ignored issues
show
Unused Code introduced by
The assignment to $path is dead and can be removed.
Loading history...
164
165
        return File::get($path);
166
    }
167
}
168