1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Someshwer\WorldCountries\Utils; |
4
|
|
|
|
5
|
|
|
use Illuminate\Encryption\Encrypter; |
|
|
|
|
6
|
|
|
use Someshwer\WorldCountries\Data\DataRepository; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Author: Someshwer Bandapally |
10
|
|
|
* Date: 14-07-2018. |
11
|
|
|
* |
12
|
|
|
* This class gives the list of continents names |
13
|
|
|
* |
14
|
|
|
* Class Continents |
15
|
|
|
*/ |
16
|
|
|
trait Continents |
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
|
|
|
* Continents constructor. |
35
|
|
|
* |
36
|
|
|
* @param DataRepository $dataRepository |
37
|
|
|
*/ |
38
|
|
|
public function __construct(DataRepository $dataRepository) |
39
|
|
|
{ |
40
|
|
|
$this->data = $dataRepository; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get optimized continents data. |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
private function getOptimizedContinentsData() |
49
|
|
|
{ |
50
|
|
|
$all_continents_data = $this->data->continents(); |
51
|
|
|
$continents_data = $this->optimizeContinentsData($all_continents_data); |
52
|
|
|
// return $continents_data = json_decode($continents_data, true); |
53
|
|
|
return $continents_data; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Optimize continents data. |
58
|
|
|
* |
59
|
|
|
* @param $all_continents_data |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
private function optimizeContinentsData($all_continents_data) |
64
|
|
|
{ |
65
|
|
|
$str_length = strlen($all_continents_data) - 4; |
66
|
|
|
$all_continents_trimmed_data = substr($all_continents_data, 0, 2).substr($all_continents_data, 3, $str_length); |
67
|
|
|
// $hash = new Encrypter($this->en_key, Config::get('app.cipher')); |
68
|
|
|
$hash = new Encrypter($this->en_key, $this->cipher); |
69
|
|
|
$all_continents = $hash->decrypt($all_continents_trimmed_data); |
70
|
|
|
|
71
|
|
|
return $all_continents; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Format continents. |
76
|
|
|
* |
77
|
|
|
* @param $continents |
78
|
|
|
* |
79
|
|
|
* @return $this |
80
|
|
|
*/ |
81
|
|
|
private function formatContinents($continents) |
82
|
|
|
{ |
83
|
|
|
return collect($continents)->transform(function ($item) { |
|
|
|
|
84
|
|
|
$data['name'] = $item; |
|
|
|
|
85
|
|
|
$data['display_name'] = str_replace('_', ' ', title_case($item)); |
|
|
|
|
86
|
|
|
$data['also_called_as'] = ($item == 'australia') ? 'Oceania' : null; |
87
|
|
|
|
88
|
|
|
return $data; |
89
|
|
|
}); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get list of continents names. |
94
|
|
|
* |
95
|
|
|
* @return array |
96
|
|
|
*/ |
97
|
|
|
public function continents() |
98
|
|
|
{ |
99
|
|
|
$continents = $this->getOptimizedContinentsData(); |
100
|
|
|
$formatted_continents = $this->formatContinents($continents); |
101
|
|
|
|
102
|
|
|
return ['continents' => $formatted_continents]; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
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