Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for composer 2.0 #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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