|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rs\VersionEye\Output; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Products. |
|
9
|
|
|
* |
|
10
|
|
|
* @author Robert Schönthal <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class Products extends BaseOutput |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* output for the search API. |
|
16
|
|
|
* |
|
17
|
|
|
* @param OutputInterface $output |
|
18
|
|
|
* @param array $response |
|
19
|
|
|
*/ |
|
20
|
1 |
|
public function search(OutputInterface $output, array $response) |
|
21
|
|
|
{ |
|
22
|
1 |
|
$this->printProducts($output, $response['results']); |
|
23
|
1 |
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* output for the references API. |
|
27
|
|
|
* |
|
28
|
|
|
* @param OutputInterface $output |
|
29
|
|
|
* @param array $response |
|
30
|
|
|
*/ |
|
31
|
1 |
|
public function references(OutputInterface $output, array $response) |
|
32
|
|
|
{ |
|
33
|
1 |
|
$this->printProducts($output, $response['results']); |
|
34
|
1 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* output for the show API. |
|
38
|
|
|
* |
|
39
|
|
|
* @param OutputInterface $output |
|
40
|
|
|
* @param array $response |
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function show(OutputInterface $output, array $response) |
|
43
|
|
|
{ |
|
44
|
1 |
|
$this->printList($output, |
|
45
|
1 |
|
['Name', 'Description', 'Source', 'Archive', 'Key', 'Type', 'License', 'Version', 'Group', 'Updated At'], |
|
46
|
1 |
|
['name', 'description', 'links', 'archives', 'prod_key', 'prod_type', 'license_info', 'version', 'group_id', 'updated_at'], |
|
47
|
|
|
$response, |
|
48
|
|
|
function ($heading, $value) { |
|
49
|
1 |
|
if ('Source' === $heading) { |
|
50
|
1 |
|
if (!empty($value)) { |
|
51
|
1 |
|
return array_pop($value)['link']; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
1 |
|
if ('Archive' === $heading) { |
|
56
|
1 |
|
return array_pop($value)['link']; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
return $value; |
|
60
|
1 |
|
} |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
1 |
|
$this->printTable($output, |
|
64
|
1 |
|
['Name', 'Current', 'Requested'], |
|
65
|
1 |
|
['name', 'parsed_version', 'version'], |
|
66
|
1 |
|
$response['dependencies'] |
|
67
|
|
|
); |
|
68
|
1 |
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* output for the follow status API. |
|
72
|
|
|
* |
|
73
|
|
|
* @param OutputInterface $output |
|
74
|
|
|
* @param array $response |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function followStatus(OutputInterface $output, array $response) |
|
77
|
|
|
{ |
|
78
|
1 |
|
$this->printBoolean($output, 'YES', 'NO', true === $response['follows']); |
|
79
|
1 |
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* output for the follow API. |
|
83
|
|
|
* |
|
84
|
|
|
* @param OutputInterface $output |
|
85
|
|
|
* @param array $response |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function follow(OutputInterface $output, array $response) |
|
88
|
|
|
{ |
|
89
|
1 |
|
$this->printBoolean($output, 'OK', 'FAIL', true === $response['follows']); |
|
90
|
1 |
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* output for the unfollow API. |
|
94
|
|
|
* |
|
95
|
|
|
* @param OutputInterface $output |
|
96
|
|
|
* @param array $response |
|
97
|
|
|
*/ |
|
98
|
1 |
|
public function unfollow(OutputInterface $output, array $response) |
|
99
|
|
|
{ |
|
100
|
1 |
|
$this->printBoolean($output, 'OK', 'FAIL', false === $response['follows']); |
|
101
|
1 |
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* output for the versions API. |
|
105
|
|
|
* |
|
106
|
|
|
* @param OutputInterface $output |
|
107
|
|
|
* @param array $response |
|
108
|
|
|
*/ |
|
109
|
1 |
|
public function versions(OutputInterface $output, array $response) |
|
110
|
|
|
{ |
|
111
|
1 |
|
$this->printList($output, |
|
112
|
1 |
|
['Name', 'Language', 'Key', 'Type', 'Version'], |
|
113
|
1 |
|
['name', 'language', 'prod_key', 'prod_type', 'version'], |
|
114
|
1 |
|
$response |
|
115
|
|
|
); |
|
116
|
|
|
|
|
117
|
1 |
|
$this->printTable($output, |
|
118
|
1 |
|
['Version', 'Released At'], |
|
119
|
1 |
|
['version', 'released_at'], |
|
120
|
1 |
|
$response['versions'], |
|
121
|
1 |
|
function ($key, $value) { |
|
122
|
1 |
|
if ('released_at' !== $key) { |
|
123
|
1 |
|
return $value; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
1 |
|
return date('Y-m-d H:i:s', strtotime($value)); |
|
127
|
1 |
|
} |
|
128
|
|
|
); |
|
129
|
1 |
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|