<commit_before><?php

namespace Office365\PHP\Client\Runtime;

use Office365\PHP\Client\Runtime\Auth\IAuthenticationContext;
use Office365\PHP\Client\Runtime\OData\ODataFormat;
use Office365\PHP\Client\Runtime\OData\ODataPayload;
use Office365\PHP\Client\Runtime\OData\ODataQueryOptions;
use Office365\PHP\Client\Runtime\Utilities\RequestOptions;

/**
 * OData Runtime context for Office365 APIs
 */
class ClientRuntimeContext
{
    /**
     * Service Root url
     * @var string
     */
    private $serviceRootUrl;

    /**
     * Service version
     * @var string
     */
    private $version;

    /**
     * @var IAuthenticationContext
     */
    private $authContext;

    /**
     * @var ClientRequest
     */
    private $pendingRequest;

    /**
     * @var ODataFormat
     */
    protected $format;

    /**
     * REST client context ctor
     * @param string $serviceUrl
     * @param IAuthenticationContext $authContext
     * @param ODataFormat $format
     * @param string $version
     */
    public function __construct($serviceUrl, IAuthenticationContext $authContext, ODataFormat $format, $version = Office365Version::V1)
    {
        $this->version = $version;
        $this->serviceRootUrl = $serviceUrl;
        $this->authContext = $authContext;
        $this->format = $format;
    }

    /**
     * @param RequestOptions $options
     */
    public function authenticateRequest(RequestOptions $options)
    {
        $this->authContext->authenticateRequest($options);
    }

    /**
     * Gets the service root URL that identifies the root of an OData service
     * @return string
     */
    public function getServiceRootUrl()
    {
        return $this->serviceRootUrl;
    }

    /**
     * Gets the api version being used
     * @return string
     */
    public function getApiVersion()
    {
        return $this->version;
    }

    /**
     * Prepare to load resource
     * @param ClientObject $clientObject
     * @param ODataQueryOptions $queryOptions
     *
     * @return self
     */
    public function load(ClientObject $clientObject, ODataQueryOptions $queryOptions = null)
    {
        $this->getPendingRequest()->addQueryAndResultObject($clientObject, $queryOptions);
        return $this;
    }

    /**
     * Submit client request to SharePoint OData/SOAP service
     *
     * @return self
     */
    public function executeQuery()
    {
        $this->getPendingRequest()->executeQuery();
        return $this;
    }

    /**
     * @param RequestOptions $options
     * @return ODataPayload
     */
    public function executeQueryDirect(RequestOptions $options)
    {
        return $this->getPendingRequest()->executeQueryDirect($options);
    }

    /**
     * @param $response
     * @param $resultObject
     * @return self
     */
    public function populateObject($response, $resultObject)
    {
        $this->getPendingRequest()->populateObject($response, $resultObject);
        return $this;
    }

    /**
     * @param ClientAction $query
     * @param ClientObject $resultObject
     * @return self
     */
    public function addQuery(ClientAction $query, $resultObject = null)
    {
        $this->getPendingRequest()->addQuery($query, $resultObject);
        return $this;
    }

    /**
     * @return ClientRequest
     */
    public function getPendingRequest()
    {
        if (!isset($this->pendingRequest)) {
            $this->pendingRequest = new ClientRequest($this, $this->format);
        }
        return $this->pendingRequest;
    }

}
<commit_msg>Fixed issue with second parameter for ClientRuntimeContext.Load method<commit_after><?php

namespace Office365\PHP\Client\Runtime;

use Office365\PHP\Client\Runtime\Auth\IAuthenticationContext;
use Office365\PHP\Client\Runtime\OData\ODataFormat;
use Office365\PHP\Client\Runtime\OData\ODataPayload;
use Office365\PHP\Client\Runtime\OData\ODataQueryOptions;
use Office365\PHP\Client\Runtime\Utilities\RequestOptions;

/**
 * OData Runtime context for Office365 APIs
 */
class ClientRuntimeContext
{
    /**
     * Service Root url
     * @var string
     */
    private $serviceRootUrl;

    /**
     * Service version
     * @var string
     */
    private $version;

    /**
     * @var IAuthenticationContext
     */
    private $authContext;

    /**
     * @var ClientRequest
     */
    private $pendingRequest;

    /**
     * @var ODataFormat
     */
    protected $format;

    /**
     * REST client context ctor
     * @param string $serviceUrl
     * @param IAuthenticationContext $authContext
     * @param ODataFormat $format
     * @param string $version
     */
    public function __construct($serviceUrl, IAuthenticationContext $authContext, ODataFormat $format, $version = Office365Version::V1)
    {
        $this->version = $version;
        $this->serviceRootUrl = $serviceUrl;
        $this->authContext = $authContext;
        $this->format = $format;
    }

    /**
     * @param RequestOptions $options
     */
    public function authenticateRequest(RequestOptions $options)
    {
        $this->authContext->authenticateRequest($options);
    }

    /**
     * Gets the service root URL that identifies the root of an OData service
     * @return string
     */
    public function getServiceRootUrl()
    {
        return $this->serviceRootUrl;
    }

    /**
     * Gets the api version being used
     * @return string
     */
    public function getApiVersion()
    {
        return $this->version;
    }

    /**
     * Prepare to load resource
     * @param ClientObject $clientObject
     * @param array $selectProperties
     * @return ClientRuntimeContext
     *
     */
    public function load(ClientObject $clientObject, array $selectProperties = null)
    {
        if(!is_null($selectProperties)) {
            $queryOptions = new ODataQueryOptions();
            $queryOptions->Select = implode(",",$selectProperties);
            $this->getPendingRequest()->addQueryAndResultObject($clientObject, $queryOptions);
        }
        else
            $this->getPendingRequest()->addQueryAndResultObject($clientObject);
        return $this;
    }

    /**
     * Submit client request to SharePoint OData/SOAP service
     *
     * @return self
     */
    public function executeQuery()
    {
        $this->getPendingRequest()->executeQuery();
        return $this;
    }

    /**
     * @param RequestOptions $options
     * @return ODataPayload
     */
    public function executeQueryDirect(RequestOptions $options)
    {
        return $this->getPendingRequest()->executeQueryDirect($options);
    }

    /**
     * @param $response
     * @param $resultObject
     * @return self
     */
    public function populateObject($response, $resultObject)
    {
        $this->getPendingRequest()->populateObject($response, $resultObject);
        return $this;
    }

    /**
     * @param ClientAction $query
     * @param ClientObject $resultObject
     * @return self
     */
    public function addQuery(ClientAction $query, $resultObject = null)
    {
        $this->getPendingRequest()->addQuery($query, $resultObject);
        return $this;
    }

    /**
     * @return ClientRequest
     */
    public function getPendingRequest()
    {
        if (!isset($this->pendingRequest)) {
            $this->pendingRequest = new ClientRequest($this, $this->format);
        }
        return $this->pendingRequest;
    }

}

{'fraction_non_alphanumeric': 0.11357191087103309, 'fraction_numerical': 0.00675219446320054, 'mean_word_length': 2.4639850327408794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5378823', 'n_tokens_mistral': 2080, 'n_tokens_neox': 2026, 'n_words': 443}