WC_Connect_Loader::get_service_object_by_id PHP Method

get_service_object_by_id() protected method

Returns a reference to a service (e.g. WC_Connect_Shipping_Method) of a particular id so we can avoid instantiating them multiple times
protected get_service_object_by_id ( string $class_name, string $service_id ) : mixed
$class_name string Class name of service to create (e.g. WC_Connect_Shipping_Method)
$service_id string Service id of service to create (e.g. usps)
return mixed
        protected function get_service_object_by_id($class_name, $service_id)
        {
            if (!array_key_exists($service_id, $this->service_object_cache)) {
                $this->service_object_cache[$service_id] = new $class_name($service_id);
            }
            return $this->service_object_cache[$service_id];
        }
WC_Connect_Loader