Skip to content

Commit

Permalink
Added support for composer 2.0
Browse files Browse the repository at this point in the history
* Removed thadafinser/package-info and use
composer-runtime-api
  • Loading branch information
duxthefux committed Oct 25, 2020
1 parent b592e23 commit c7bdbab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"require": {
"php": "~5.6|~7.0",
"guzzlehttp/guzzle": "^6.1",
"thadafinser/package-info": "^1.0"
"composer-runtime-api": "^2.0"
},

"conflict": {
Expand Down
19 changes: 5 additions & 14 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
namespace UserAgentParser\Provider;

use Composer\InstalledVersions;
use DateTime;
use PackageInfo\Exception\PackageNotInstalledException;
use PackageInfo\Package;
use UserAgentParser\Exception;
use UserAgentParser\Exception\PackageNotLoadedException;
use UserAgentParser\Model;
Expand Down Expand Up @@ -123,10 +122,8 @@ public function getPackageName()
public function getVersion()
{
try {
$package = new Package($this->getPackageName());

return $package->getVersion();
} catch (PackageNotInstalledException $ex) {
return InstalledVersions::getVersion($this->getPackageName());
} catch (\OutOfBoundsException $ex) {
return;
}
}
Expand All @@ -138,13 +135,7 @@ public function getVersion()
*/
public function getUpdateDate()
{
try {
$package = new Package($this->getPackageName());

return $package->getVersionReleaseDate();
} catch (PackageNotInstalledException $ex) {
return;
}
return;
}

/**
Expand All @@ -163,7 +154,7 @@ public function getDetectionCapabilities()
*/
protected function checkIfInstalled()
{
if (! Package::isInstalled($this->getPackageName())) {
if (! InstalledVersions::isInstalled($this->getPackageName())) {
throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider');
}
}
Expand Down

0 comments on commit c7bdbab

Please sign in to comment.