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
|
|
|
* Provides the data of world wonders |
13
|
|
|
* |
14
|
|
|
* Class Wonders |
15
|
|
|
*/ |
16
|
|
|
trait Wonders |
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
|
|
|
public function __construct(DataRepository $dataRepository) |
34
|
|
|
{ |
35
|
|
|
$this->data = $dataRepository; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Optimizes wonders data. |
40
|
|
|
* |
41
|
|
|
* @param $all_wonders_data |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
private function optimizeWondersData($all_wonders_data) |
46
|
|
|
{ |
47
|
|
|
$str_length = strlen($all_wonders_data) - 4; |
48
|
|
|
$all_wonders_trimmed_data = substr($all_wonders_data, 0, 2).substr($all_wonders_data, 3, $str_length); |
49
|
|
|
$hash = new Encrypter($this->en_key, $this->cipher); |
50
|
|
|
|
51
|
|
|
return $hash->decrypt($all_wonders_trimmed_data); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Fetches wonders data from a file and processes it. |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
private function getOptimizedWondersData() |
60
|
|
|
{ |
61
|
|
|
$all_wonders_data = $this->data->wonders(); |
62
|
|
|
$territories_data = $this->optimizeWondersData($all_wonders_data); |
63
|
|
|
|
64
|
|
|
return $territories_data; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Formats wonders data. |
69
|
|
|
* |
70
|
|
|
* @param $wonders |
71
|
|
|
* |
72
|
|
|
* @return static |
73
|
|
|
*/ |
74
|
|
|
private function formatWonders($wonders) |
75
|
|
|
{ |
76
|
|
|
return collect($wonders)->transform(function ($item, $key) { |
|
|
|
|
77
|
|
|
$data['name'] = $key; |
|
|
|
|
78
|
|
|
$data['display_name'] = str_replace('_', ' ', title_case($key)); |
|
|
|
|
79
|
|
|
$data['location'] = str_replace('_', ' ', title_case($item)); |
80
|
|
|
|
81
|
|
|
return $data; |
82
|
|
|
})->values(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns all wonders names. |
87
|
|
|
* |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function wonders() |
91
|
|
|
{ |
92
|
|
|
$wonders = $this->getOptimizedWondersData(); |
93
|
|
|
$formatted_wonders = $this->formatWonders($wonders); |
94
|
|
|
|
95
|
|
|
return ['wonders_of_the_world' => $formatted_wonders]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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