Skip to content

Commit c7bdbab

Browse files
committed
Added support for composer 2.0
* Removed thadafinser/package-info and use composer-runtime-api
1 parent b592e23 commit c7bdbab

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"require": {
7272
"php": "~5.6|~7.0",
7373
"guzzlehttp/guzzle": "^6.1",
74-
"thadafinser/package-info": "^1.0"
74+
"composer-runtime-api": "^2.0"
7575
},
7676

7777
"conflict": {

src/Provider/AbstractProvider.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
namespace UserAgentParser\Provider;
33

4+
use Composer\InstalledVersions;
45
use DateTime;
5-
use PackageInfo\Exception\PackageNotInstalledException;
6-
use PackageInfo\Package;
76
use UserAgentParser\Exception;
87
use UserAgentParser\Exception\PackageNotLoadedException;
98
use UserAgentParser\Model;
@@ -123,10 +122,8 @@ public function getPackageName()
123122
public function getVersion()
124123
{
125124
try {
126-
$package = new Package($this->getPackageName());
127-
128-
return $package->getVersion();
129-
} catch (PackageNotInstalledException $ex) {
125+
return InstalledVersions::getVersion($this->getPackageName());
126+
} catch (\OutOfBoundsException $ex) {
130127
return;
131128
}
132129
}
@@ -138,13 +135,7 @@ public function getVersion()
138135
*/
139136
public function getUpdateDate()
140137
{
141-
try {
142-
$package = new Package($this->getPackageName());
143-
144-
return $package->getVersionReleaseDate();
145-
} catch (PackageNotInstalledException $ex) {
146-
return;
147-
}
138+
return;
148139
}
149140

150141
/**
@@ -163,7 +154,7 @@ public function getDetectionCapabilities()
163154
*/
164155
protected function checkIfInstalled()
165156
{
166-
if (! Package::isInstalled($this->getPackageName())) {
157+
if (! InstalledVersions::isInstalled($this->getPackageName())) {
167158
throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider');
168159
}
169160
}

0 commit comments

Comments
 (0)