Browse Source

Add PlatformRepository::PLATFORM_PACKAGE_REGEX to remove duplication

Jordi Boggiano 12 years ago
parent
commit
d38eb244fa

+ 1 - 1
src/Composer/Installer.php

@@ -717,7 +717,7 @@ class Installer
     private function extractPlatformRequirements($links) {
         $platformReqs = array();
         foreach ($links as $link) {
-            if (preg_match('{^(?:php(?:-64bit)?|(?:ext|lib)-[^/]+)$}i', $link->getTarget())) {
+            if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
                 $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
             }
         }

+ 1 - 1
src/Composer/Repository/ComposerRepository.php

@@ -240,7 +240,7 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
         }
 
         // skip platform packages
-        if (preg_match('{^(?:php(?:-64bit)?|(?:ext|lib)-[^/]+)$}i', $name) || '__root__' === $name) {
+        if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) {
             return array();
         }
 

+ 2 - 0
src/Composer/Repository/PlatformRepository.php

@@ -20,6 +20,8 @@ use Composer\Package\Version\VersionParser;
  */
 class PlatformRepository extends ArrayRepository
 {
+    const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit)?|(?:ext|lib)-[^/]+)$}i';
+
     protected function initialize()
     {
         parent::initialize();