<?php

/**
 * The is the factory which creates shipment tracking objects
 */
class PH_Basic_TrackingFactory {
	public static function init() {
		PH_Basic_TrackingFactory::wf_include_once( 'PH_Basic_TrackingAbstract', 'class-wf-tracking-common.php' );
		PH_Basic_TrackingFactory::wf_include_once( 'PH_Basic_TrackingAbstract', 'class-wf-tracking-abstract.php' );
	}

    public static function create( $shipment_source_obj ) {	
        switch ( $shipment_source_obj->shipping_service ) {
			case '':
                $tracking_obj = null;
				break;
            case 'wf_usps':
			default:
				PH_Basic_TrackingFactory::wf_include_once( 'PH_Basic_TrackingDefault', 'class-wf-tracking-default.php' );
				$tracking_obj = new PH_Basic_TrackingDefault();
				break;
        }

		if( null != $tracking_obj ) {
			$tracking_obj->init ( $shipment_source_obj );
		}

        return $tracking_obj;
    }

	private static function wf_include_once( $class_name, $file_name ) {
		if ( ! class_exists( $class_name ) ) {
			include_once ( $file_name );
		}
	}
}

?>