<commit_before><?php

namespace BCLib\XServices;

require_once('HTTP/Request2.php');

abstract class Request
{

    private $_url = 'http://bc-primo.hosted.exlibrisgroup.com/PrimoWebServices/xservice/';
    private $_arguments = array();
    private $_translator;
    private $_xml;

    public function __construct(Translator $translator)
    {
        $this->_translator = $translator;
    }

    protected function _setUrl($url)
    {
        $this->_url = $url;
    }

    public function send(\HTTP_Request2 $request)
    {
        $this->_url .= '?' . implode('&', $this->_arguments);

        $request->setUrl($this->_url);
        $this->_xml = $request->send()->getBody();
        $xml = simplexml_load_string($this->_xml);
        return $this->_translator->translate($xml);
    }

    protected function _addArgument($parameter, $value)
    {
        $this->_arguments[] = "$parameter=$value";
    }

    public function setInstitution($institution)
    {
        $this->_addArgument('institution', $institution);
    }

    public function getXML()
    {
        return $this->_xml;
    }
    
    public function __toString()
    {
        return $this->_url;
    }

}<commit_msg>Smarter way of getting URL<commit_after><?php

namespace BCLib\XServices;

require_once('HTTP/Request2.php');

abstract class Request
{

    private $_url = 'http://bc-primo.hosted.exlibrisgroup.com/PrimoWebServices/xservice/';
    private $_arguments = array();
    private $_translator;
    private $_xml;

    public function __construct(Translator $translator)
    {
        $this->_translator = $translator;
    }

    protected function _setUrl($url)
    {
        $this->_url = $url;
    }

    public function send(\HTTP_Request2 $request)
    {
        $this->_url .= '?' . implode('&', $this->_arguments);

        $request->setUrl($this->_url);
        $this->_xml = $request->send()->getBody();
        $xml = simplexml_load_string($this->_xml);
        return $this->_translator->translate($xml);
    }

    protected function _addArgument($parameter, $value)
    {
        $this->_arguments[] = "$parameter=$value";
    }

    public function setInstitution($institution)
    {
        $this->_addArgument('institution', $institution);
    }

    public function getXML()
    {
        return $this->_xml;
    }

    public function __toString()
    {
        return $this->_url .= '?' . implode('&', $this->_arguments);

    }

}
{'fraction_non_alphanumeric': 0.15141567501025852, 'fraction_numerical': 0.0016413623307345096, 'mean_word_length': 2.7051671732522795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6244731', 'n_tokens_mistral': 752, 'n_tokens_neox': 734, 'n_words': 132}