blob: 64c69ef52939fab852f57a6fa06f31499f1023b2 (
plain)
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
|
<?php
use Composer\Package\Link;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Package\Package;
/**
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class ComposerPackageModifier {
const MEDIAWIKI_PACKAGE_NAME = 'mediawiki/mediawiki';
protected $package;
protected $versionNormalizer;
protected $versionFetcher;
public function __construct( Package $package,
ComposerVersionNormalizer $versionNormalizer, MediaWikiVersionFetcher $versionFetcher
) {
$this->package = $package;
$this->versionNormalizer = $versionNormalizer;
$this->versionFetcher = $versionFetcher;
}
public function setProvidesMediaWiki() {
$this->setLinkAsProvides( $this->newMediaWikiLink() );
}
private function setLinkAsProvides( Link $link ) {
$this->package->setProvides( array( $link ) );
}
private function newMediaWikiLink() {
$version = $this->getMediaWikiVersionConstraint();
$link = new Link(
'__root__',
self::MEDIAWIKI_PACKAGE_NAME,
$version,
'provides',
$version->getPrettyString()
);
return $link;
}
private function getMediaWikiVersionConstraint() {
$mvVersion = $this->versionFetcher->fetchVersion();
$mvVersion = $this->versionNormalizer->normalizeSuffix( $mvVersion );
$version = new VersionConstraint(
'==',
$this->versionNormalizer->normalizeLevelCount( $mvVersion )
);
$version->setPrettyString( $mvVersion );
return $version;
}
}
|