1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright 2012 Johannes M. Schmitt <[email protected]> |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace JMS\Composer\Graph; |
20
|
|
|
|
21
|
|
|
class DependencyEdge |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var PackageNode |
25
|
|
|
*/ |
26
|
|
|
private $sourcePackage; |
27
|
|
|
/** |
28
|
|
|
* @var PackageNode |
29
|
|
|
*/ |
30
|
|
|
private $destPackage; |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $versionConstraint; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param PackageNode $sourcePackage |
38
|
|
|
* @param PackageNode $destPackage |
39
|
|
|
* @param string $versionConstraint |
40
|
|
|
*/ |
41
|
|
|
public function __construct(PackageNode $sourcePackage, PackageNode $destPackage, $versionConstraint) |
42
|
|
|
{ |
43
|
|
|
$this->sourcePackage = $sourcePackage; |
44
|
|
|
$this->destPackage = $destPackage; |
45
|
|
|
$this->versionConstraint = $versionConstraint; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getVersionConstraint() |
52
|
|
|
{ |
53
|
|
|
return $this->versionConstraint; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return PackageNode |
58
|
|
|
*/ |
59
|
|
|
public function getSourcePackage() |
60
|
|
|
{ |
61
|
|
|
return $this->sourcePackage; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return PackageNode |
66
|
|
|
*/ |
67
|
|
|
public function getDestPackage() |
68
|
|
|
{ |
69
|
|
|
return $this->destPackage; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
|
|
public function isDevDependency() |
76
|
|
|
{ |
77
|
|
|
return $this->sourcePackage->hasDataPackageKey('require-dev', $this->destPackage->getName()); |
78
|
|
|
} |
79
|
|
|
} |