Common/Factory/SaleFactory.php
private function resolveClassAndCreateObject($type, $subject)
    {
        foreach ($this->classes[$type] as $source => $target) {
            if ($subject instanceof $source) {
                return new $target;
            }
        }

        throw new InvalidArgumentException('Unsupported object class.');
    }
private function resolveClassAndCreateObject($type, $subject)
    {
        foreach ($this->classes[$type] as $source => $target) {
            if ($subject instanceof $source) {
                return new $target;
            }
        }

        throw new InvalidArgumentException('Unsupported object class.');
    }
Resolves the class and creates the expected object.

@param string $type
@param object $subject

@return object