1 | <?php |
||||
2 | |||||
3 | namespace Someshwer\WorldCountries\Lib; |
||||
4 | |||||
5 | use Illuminate\Encryption\Encrypter; |
||||
0 ignored issues
–
show
|
|||||
6 | use Someshwer\WorldCountries\Data\DataRepository; |
||||
7 | |||||
8 | /** |
||||
9 | * Author: Someshwer Bandapally |
||||
10 | * Date: 14-07-2018. |
||||
11 | * |
||||
12 | * This class gives all country names |
||||
13 | * |
||||
14 | * Class Countries |
||||
15 | */ |
||||
16 | class Countries extends ISOCodes |
||||
17 | { |
||||
18 | /** |
||||
19 | * @var DataRepository |
||||
20 | */ |
||||
21 | private $data; |
||||
22 | |||||
23 | /** |
||||
24 | * @var string |
||||
25 | */ |
||||
26 | private $en_key = 'Someshwer1@2#BandapallySomeshwer'; |
||||
27 | |||||
28 | /** |
||||
29 | * @var string |
||||
30 | */ |
||||
31 | private $cipher = 'AES-256-CBC'; |
||||
32 | |||||
33 | /** |
||||
34 | * Countries constructor. |
||||
35 | * |
||||
36 | * @param DataRepository $dataRepository |
||||
37 | */ |
||||
38 | public function __construct(DataRepository $dataRepository) |
||||
39 | { |
||||
40 | parent::__construct($dataRepository); |
||||
41 | $this->data = $dataRepository; |
||||
42 | } |
||||
43 | |||||
44 | /** |
||||
45 | * Optimizing the country data. |
||||
46 | * |
||||
47 | * @param $all_countries_data |
||||
48 | * |
||||
49 | * @return string |
||||
50 | */ |
||||
51 | private function optimizeCountryData($all_countries_data) |
||||
52 | { |
||||
53 | $str_length = strlen($all_countries_data) - 4; |
||||
54 | $all_countries_trimmed_data = substr($all_countries_data, 0, 2).substr($all_countries_data, 3, $str_length); |
||||
55 | // $hash = new Encrypter($this->en_key, Config::get('app.cipher')); |
||||
56 | $hash = new Encrypter($this->en_key, $this->cipher); |
||||
57 | $all_countries = $hash->decrypt($all_countries_trimmed_data); |
||||
58 | |||||
59 | return $all_countries; |
||||
60 | } |
||||
61 | |||||
62 | /** |
||||
63 | * Get all countries. |
||||
64 | * |
||||
65 | * @return array |
||||
66 | */ |
||||
67 | public function countries() |
||||
68 | { |
||||
69 | $all_countries_data = $this->data->countries(); |
||||
70 | $all_countries = $this->optimizeCountryData($all_countries_data); |
||||
71 | $countries = collect($all_countries)->map(function ($item) { |
||||
0 ignored issues
–
show
The function
collect 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
![]() |
|||||
72 | // return title_case(str_replace('-',' ', $item)); |
||||
73 | return studly_case($item); |
||||
0 ignored issues
–
show
The function
studly_case 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
![]() |
|||||
74 | }); |
||||
75 | |||||
76 | return ['countries' => $countries]; |
||||
77 | } |
||||
78 | |||||
79 | /** |
||||
80 | * Search country by search string. |
||||
81 | * |
||||
82 | * @param $search_string |
||||
83 | * |
||||
84 | * @return array |
||||
85 | */ |
||||
86 | public function searchCountry($search_string = null) |
||||
87 | { |
||||
88 | $all_countries_data = $this->data->countries(); |
||||
89 | $all_countries = $this->optimizeCountryData($all_countries_data); |
||||
90 | if ($search_string == null) { |
||||
91 | return array_map(function ($it) { |
||||
92 | return studly_case($it); |
||||
0 ignored issues
–
show
The function
studly_case 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
![]() |
|||||
93 | }, $all_countries); |
||||
0 ignored issues
–
show
$all_countries of type string is incompatible with the type array expected by parameter $arr1 of array_map() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
94 | } |
||||
95 | $countries = array_map(function ($it) { |
||||
96 | return studly_case($it); |
||||
0 ignored issues
–
show
The function
studly_case 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
![]() |
|||||
97 | }, array_filter($all_countries, function ($item) use ($search_string) { |
||||
0 ignored issues
–
show
$all_countries of type string is incompatible with the type array expected by parameter $input of array_filter() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
98 | return strpos($item, strtolower($search_string)) === 0; |
||||
99 | })); |
||||
100 | |||||
101 | return ['countries' => array_values($countries)]; |
||||
102 | } |
||||
103 | } |
||||
104 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths