'EXPRESS', * 'weight' => '80', * 'shipperState' => 'MN', * 'shipperPostalCode' => '55114', * 'shipToState' => 'MN', * 'shipToPostalCode' => '55411', * 'addressType' => 'residential' * )); */ class App_Service_Shipping { /** * @static * @param $service * @param array $options * @return App_Service_Shipping_Abstract * @throws Qs_Exception */ public static function factory($service, $options = array()) { if (!is_array($options)) { throw new Qs_Exception('Service options must be in an array'); } if (!is_string($service) || empty($service)) { throw new Qs_Exception('Service name must be specified in a string'); } $serviceClassName = str_replace(' ', '_', ucwords(str_replace('_', ' ', __CLASS__ . '_' . $service))); /** Load the service class. This throws an exception if the specified class cannot be loaded. */ Zend_Loader::loadClass($serviceClassName); $service = new $serviceClassName($options); if (! $service instanceof App_Service_Shipping_Abstract) { throw new Qs_Exception( 'Service class ' . $serviceClassName . ' does not extend App_Service_Shipping_Abstract_Abstract' ); } return $service; } }