Repository navigation
Expand file tree
/
Copy pathComparison.php
More file actions
73 lines (63 loc) · 1.71 KB
/
Copy pathComparison.php
File metadata and controls
73 lines (63 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php namespace Gitlab\Model;
use Gitlab\Client;
/**
* Class Comparison
*
* @property-read bool $compare_timeout
* @property-read bool $compare_same_ref
* @property-read Commit $commit
* @property-read Commit[] $commits
* @property-read Diff[] $diffs
* @property-read Project $project
*/
class Comparison extends AbstractModel
{
/**
* @var array
*/
protected static $properties = array(
'commit',
'commits',
'diffs',
'compare_timeout',
'compare_same_ref',
'project'
);
/**
* @param Client $client
* @param Project $project
* @param array $data
* @return Comparison
*/
public static function fromArray(Client $client, Project $project, array $data)
{
$file = new static($project, $client);
if (isset($data['commit'])) {
$data['commit'] = Commit::fromArray($client, $project, $data['commit']);
}
if (isset($data['commits'])) {
$commits = array();
foreach ($data['commits'] as $commit) {
$commits[] = Commit::fromArray($client, $project, $commit);
}
$data['commits'] = $commits;
}
if (isset($data['diffs'])) {
$diffs = array();
foreach ($data['diffs'] as $diff) {
$diffs[] = Diff::fromArray($client, $project, $diff);
}
$data['diffs'] = $diffs;
}
return $file->hydrate($data);
}
/**
* @param Project $project
* @param Client $client
*/
public function __construct(Project $project, Client $client = null)
{
$this->setClient($client);
$this->setData('project', $project);
}
}