Overview

Packages

  • Pear

Classes

  • Horde_Pear_Exception
  • Horde_Pear_Package_Contents_Ignore_Composite
  • Horde_Pear_Package_Contents_Ignore_Dot
  • Horde_Pear_Package_Contents_Ignore_Git
  • Horde_Pear_Package_Contents_Ignore_Hidden
  • Horde_Pear_Package_Contents_Ignore_Nothing
  • Horde_Pear_Package_Contents_Ignore_Patterns
  • Horde_Pear_Package_Contents_Include_All
  • Horde_Pear_Package_Contents_InstallAs_Horde
  • Horde_Pear_Package_Contents_InstallAs_HordeApplication
  • Horde_Pear_Package_Contents_InstallAs_HordeComponent
  • Horde_Pear_Package_Contents_InstallAs_HordeRole
  • Horde_Pear_Package_Contents_List
  • Horde_Pear_Package_Contents_Role_HordeApplication
  • Horde_Pear_Package_Contents_Role_HordeComponent
  • Horde_Pear_Package_Dependencies
  • Horde_Pear_Package_Task_UpdateContents
  • Horde_Pear_Package_Type_Horde
  • Horde_Pear_Package_Xml
  • Horde_Pear_Package_Xml_Contents
  • Horde_Pear_Package_Xml_Directory
  • Horde_Pear_Package_Xml_Element_Directory
  • Horde_Pear_Package_Xml_Element_File
  • Horde_Pear_Package_Xml_Factory
  • Horde_Pear_Registry
  • Horde_Pear_Remote
  • Horde_Pear_Rest
  • Horde_Pear_Rest_Dependencies
  • Horde_Pear_Rest_Package
  • Horde_Pear_Rest_PackageList
  • Horde_Pear_Rest_Release
  • Horde_Pear_Rest_Releases

Interfaces

  • Horde_Pear_Package_Contents
  • Horde_Pear_Package_Contents_Ignore
  • Horde_Pear_Package_Contents_Include
  • Horde_Pear_Package_Contents_InstallAs
  • Horde_Pear_Package_Contents_Role
  • Horde_Pear_Package_Task
  • Horde_Pear_Package_Type
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Handles dependency conversions.
  4:  *
  5:  * PHP version 5
  6:  *
  7:  * @category Horde
  8:  * @package  Pear
  9:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 10:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 11:  * @link     http://pear.horde.org/index.php?package=Pear
 12:  */
 13: 
 14: /**
 15:  * Handles dependency conversions.
 16:  *
 17:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
 18:  *
 19:  * See the enclosed file COPYING for license information (LGPL). If you
 20:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 21:  *
 22:  * @category Horde
 23:  * @package  Pear
 24:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 25:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 26:  * @link     http://pear.horde.org/index.php?package=Pear
 27:  */
 28: class Horde_Pear_Package_Dependencies
 29: {
 30:     /**
 31:      * Add a dependency.
 32:      *
 33:      * @param array  $input    The input array.
 34:      * @param string $type     The dependency type.
 35:      * @param string $optional Optional dependency or not?
 36:      * @param array  &$result  The result array.
 37:      *
 38:      * @return NULL
 39:      */
 40:     static public function addDependency($input, $type, $optional, &$result)
 41:     {
 42:         switch ($type) {
 43:         case 'php':
 44:             self::addPhp($input, $result);
 45:             break;
 46:         case 'pearinstaller':
 47:             self::addPear($input, $result);
 48:             break;
 49:         case 'package':
 50:             self::addOther($input, 'pkg', $optional, $result);
 51:             break;
 52:         case 'extension':
 53:             self::addOther($input, 'ext', $optional, $result);
 54:             break;
 55:         default:
 56:             throw new Horde_Pear_Exception(
 57:                 sprintf('Unsupported dependency type "%s"!', $type)
 58:             );
 59:         }
 60:     }
 61: 
 62:     /**
 63:      * Add the PHP dependency.
 64:      *
 65:      * @param array  $input    The input array.
 66:      * @param array  &$result  The result array.
 67:      *
 68:      * @return NULL
 69:      */
 70:     static public function addPhp($input, &$result)
 71:     {
 72:         $element = array(
 73:             'type' => 'php',
 74:             'optional' => 'no',
 75:         );
 76:         self::completeVersions($input, $element, $result);
 77:     }
 78: 
 79:     /**
 80:      * Add the PEAR dependency.
 81:      *
 82:      * @param array  $input    The input array.
 83:      * @param array  &$result  The result array.
 84:      *
 85:      * @return NULL
 86:      */
 87:     static public function addPear($input, &$result)
 88:     {
 89:         $element = array(
 90:             'type' => 'pkg',
 91:             'name' => 'PEAR',
 92:             'channel' => 'pear.php.net',
 93:             'optional' => 'no',
 94:         );
 95:         self::completeVersions($input, $element, $result);
 96:     }
 97: 
 98:     /**
 99:      * Add a package dependency.
100:      *
101:      * @param array  $input    The input array.
102:      * @param array  &$result  The result array.
103:      *
104:      * @return NULL
105:      */
106:     static public function addOther($input, $type, $optional, &$result)
107:     {
108:         if (isset($input['conflicts'])) {
109:             return;
110:         }
111:         $element = $input;
112:         $element['type'] = $type;
113:         $element['optional'] = $optional;
114:         self::completeVersions($input, $element, $result);
115:     }
116: 
117:     /**
118:      * Parse version information.
119:      *
120:      * @param array  $input    The input array.
121:      * @param array  &$element The basic element information.
122:      * @param array  &$result  The result array.
123:      *
124:      * @return NULL
125:      */
126:     static public function completeVersions($input, &$element, &$result)
127:     {
128:         $added = false;
129:         if (self::_completeMin($input, $element)) {
130:             $result[] = $element;
131:             $added = true;
132:         }
133:         if (self::_completeMax($input, $element)) {
134:             $result[] = $element;
135:             $added = true;
136:         }
137:         if (!$added) {
138:             $result[] = $element;
139:         }
140:     }
141: 
142:     /**
143:      * Complete "min" version information.
144:      *
145:      * @param array  $input    The input array.
146:      * @param array  &$element The basic element information.
147:      *
148:      * @return boolean True if the was "min" information available.
149:      */
150:     static private function _completeMin($input, &$element)
151:     {
152:         if (isset($input['min'])) {
153:             $element['rel'] = 'ge';
154:             $element['version'] = $input['min'];
155:             return true;
156:         }
157:         return false;
158:     }
159: 
160:     /**
161:      * Complete "max" version information.
162:      *
163:      * @param array  $input    The input array.
164:      * @param array  &$element The basic element information.
165:      *
166:      * @return boolean True if the was "max" information available.
167:      */
168:     static private function _completeMax($input, &$element)
169:     {
170:         if (isset($input['max'])) {
171:             $element['rel'] = 'le';
172:             $element['version'] = $input['max'];
173:             return true;
174:         }
175:         return false;
176:     }
177: }
API documentation generated by ApiGen