Passed
Push — test ( 7f1499...ccf3d3 )
by Someshwer
06:32
created

DataRepository   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 149
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 149
ccs 35
cts 35
cp 1
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;
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 2
    public function countries()
33
    {
34 2
        $path = $this->base_path.'country_names.txt';
35
36 2
        return File::get($path);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Illuminate\Support\Facades\File::get($path) returns the type string which is incompatible with the documented return type array.
Loading history...
37
    }
38
39
    /**
40
     * This method reads country ISO  data from a file.
41
     *
42
     * @return mixed
43
     */
44 6
    public function countriesISOData()
45
    {
46 6
        $path = $this->base_path.'country_iso.txt';
47
48 6
        return File::get($path);
49
    }
50
51
    /**
52
     * This method reads the continents data from a file.
53
     *
54
     * @return mixed
55
     */
56 1
    public function continents()
57
    {
58 1
        $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 1
        return File::get($path);
61
    }
62
63
    /**
64
     * Reading oceans data from a file.
65
     *
66
     * @return mixed
67
     */
68 1
    public function oceans()
69
    {
70 1
        $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 1
        return File::get($path);
73
    }
74
75
    /**
76
     * Reading union territories data from a file.
77
     *
78
     * @return mixed
79
     */
80 1
    public function unionTerritories()
81
    {
82 1
        $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 1
        return File::get($path);
85
    }
86
87
    /**
88
     * Reading wonders data from a file.
89
     *
90
     * @return mixed
91
     */
92 1
    public function wonders()
93
    {
94 1
        $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 1
        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 4
    public function timezones()
108
    {
109
        // timezone_identifiers_list() is also returns same list of timezones.
110 4
        return DateTimeZone::listIdentifiers(DateTimeZone::ALL);
111
    }
112
113
    /**
114
     * Reading all currencies from a text file.
115
     *
116
     * @return mixed
117
     */
118 6
    public function currencies()
119
    {
120 6
        $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 6
        return File::get($path);
123
    }
124
125
    /**
126
     * Reading all std codes from a text file.
127
     *
128
     * @return mixed
129
     */
130 4
    public function stdCodes()
131
    {
132 4
        $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 4
        return File::get($path);
135
    }
136
137
    /**
138
     * Reading all states from a text file.
139
     *
140
     * @return mixed
141
     */
142 8
    public function states()
143
    {
144 8
        $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 8
        return File::get($path);
147
    }
148
149
    /**
150
     * Reading all countries from countries helper for states.
151
     *
152
     * @return mixed
153
     */
154 9
    public function countriesHelper()
155
    {
156 9
        $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 9
        return File::get($path);
159
    }
160
161 4
    public function cities()
162
    {
163 4
        $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 4
        return File::get($path);
166
    }
167
}
168