11<?php
22namespace UserAgentParser \Provider ;
33
4+ use Composer \InstalledVersions ;
45use DateTime ;
5- use PackageInfo \Exception \PackageNotInstalledException ;
6- use PackageInfo \Package ;
76use UserAgentParser \Exception ;
87use UserAgentParser \Exception \PackageNotLoadedException ;
98use 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