1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace AppBuilder\Application\Utils\Mapper\Factory; |
6
|
|
|
|
7
|
|
|
use AppBuilder\Application\Utils\Mapper\ArrayMapper; |
8
|
|
|
use AppBuilder\Application\Utils\Mapper\FieldMapper; |
9
|
|
|
use Closure; |
10
|
|
|
|
11
|
|
|
class BitbucketMapperFactory |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Returns a structure of mappers depending on expected result structure. |
15
|
|
|
*/ |
16
|
|
|
public static function create() : array |
17
|
|
|
{ |
18
|
|
|
/** @var Closure */ |
19
|
|
|
$stringClosure = function (string $data) : string { |
20
|
|
|
return $data; |
21
|
|
|
}; |
22
|
|
|
|
23
|
|
|
return [ |
24
|
|
|
/* Name */ |
25
|
|
|
new ArrayMapper('detail', [ |
26
|
|
|
new ArrayMapper('0', [ |
27
|
|
|
new ArrayMapper('pullRequests', [ |
28
|
|
|
new ArrayMapper('0', [ |
29
|
|
|
new FieldMapper('name', $stringClosure), |
30
|
|
|
]), |
31
|
|
|
]), |
32
|
|
|
]), |
33
|
|
|
], 'pull_request_name'), |
34
|
|
|
|
35
|
|
|
/* Url */ |
36
|
|
|
new ArrayMapper('detail', [ |
37
|
|
|
new ArrayMapper('0', [ |
38
|
|
|
new ArrayMapper('pullRequests', [ |
39
|
|
|
new ArrayMapper('0', [ |
40
|
|
|
new FieldMapper('url', $stringClosure), |
41
|
|
|
]), |
42
|
|
|
]), |
43
|
|
|
]), |
44
|
|
|
], 'pull_request_url'), |
45
|
|
|
|
46
|
|
|
/* Status */ |
47
|
|
|
new ArrayMapper('detail', [ |
48
|
|
|
new ArrayMapper('0', [ |
49
|
|
|
new ArrayMapper('pullRequests', [ |
50
|
|
|
new ArrayMapper('0', [ |
51
|
|
|
new FieldMapper('status', $stringClosure), |
52
|
|
|
]), |
53
|
|
|
]), |
54
|
|
|
]), |
55
|
|
|
], 'pull_request_status'), |
56
|
|
|
|
57
|
|
|
/* Last update */ |
58
|
|
|
new ArrayMapper('detail', [ |
59
|
|
|
new ArrayMapper('0', [ |
60
|
|
|
new ArrayMapper('pullRequests', [ |
61
|
|
|
new ArrayMapper('0', [ |
62
|
|
|
new FieldMapper('lastUpdate', $stringClosure), |
63
|
|
|
]), |
64
|
|
|
]), |
65
|
|
|
]), |
66
|
|
|
], 'pull_request_last_update'), |
67
|
|
|
|
68
|
|
|
/* Branch */ |
69
|
|
|
new ArrayMapper('detail', [ |
70
|
|
|
new ArrayMapper('0', [ |
71
|
|
|
new ArrayMapper('pullRequests', [ |
72
|
|
|
new ArrayMapper('0', [ |
73
|
|
|
new ArrayMapper('source', [ |
74
|
|
|
new FieldMapper('branch', $stringClosure), |
75
|
|
|
]), |
76
|
|
|
]), |
77
|
|
|
]), |
78
|
|
|
]), |
79
|
|
|
], 'pull_request_branch'), |
80
|
|
|
|
81
|
|
|
/* Repository */ |
82
|
|
|
new ArrayMapper('detail', [ |
83
|
|
|
new ArrayMapper('0', [ |
84
|
|
|
new ArrayMapper('pullRequests', [ |
85
|
|
|
new ArrayMapper('0', [ |
86
|
|
|
new ArrayMapper('source', [ |
87
|
|
|
new ArrayMapper('repository', [ |
88
|
|
|
new FieldMapper('name', $stringClosure), |
89
|
|
|
]), |
90
|
|
|
]), |
91
|
|
|
]), |
92
|
|
|
]), |
93
|
|
|
]), |
94
|
|
|
], 'repository'), |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|