<commit_before><?php namespace League\Fractal;

class ResourceManager
{
    protected $requestedScopes = array();
    
    public function getRequestedScopes()
    {
        return $this->requestedScopes;
    }
    
    public function setRequestedScopes(array $requestedScopes)
    {
        $this->requestedScopes = $requestedScopes;
        return $this;
    }

    public function createRootData($resource)
    {
        return $this->createData($resource);
    }

    public function createData($resource, $scopeIdentifier = null, $parentScopeInstance = null)
    {
        $scopeInstance = new Scope($this, $scopeIdentifier);

        // Update scope history
        if ($parentScopeInstance !== null) {
            
            // This will be the new childs list of partents (parents parents, plus the parent)
            $scopeArray = $parentScopeInstance->getParentScopes();
            $scopeArray[] = $parentScopeInstance->getCurrentScope();

            $scopeInstance->setParentScopes($scopeArray);
        }

        // if's n shit
        if ($resource instanceof ItemResource) {
            $data = $this->processItem($scopeInstance, $resource);
        } elseif ($resource instanceof CollectionResource) {
            $data = $this->processCollection($scopeInstance, $resource);
        } elseif ($resource instanceof PaginatorResource) {
            $data = $this->processPaginator($scopeInstance, $resource);
        } else {
            throw new Exceptions('No idea what type of resource format this is');
        }

        // So, this data is the current scope data
        $scopeInstance->setCurrentData($data);

        return $scopeInstance;
    }

    protected function getCallableProcessor(ResourceInterface $resource)
    {
        $processor = $resource->getProcessor();

        if (is_callable($processor)) {
            return $processor;
        }

        return new $processor;
    }

    protected function fireProcessor($processor, Scope $scope, $data)
    {
        // Fire Main Processor
        if (is_callable($processor)) {
            $processedData = call_user_func($processor, $data);

        } else {
            $processedData = call_user_func([$processor, 'process'], $data);

            // If its an object, process potential embeded resources
            if ($processor instanceof ProcessorAbstract) {
                $embededData = $processor->processEmbededResources($scope, $data);

                // Push the new embeds in with the main data
                $processedData = array_merge($processedData, $embededData);
            }
        }
        
        return $processedData;
    }


    protected function processItem($scope, ItemResource $resource)
    {<commit_msg>There will be murders.<commit_after><?php namespace League\Fractal;

class ResourceManager
{
    protected $requestedScopes = array();
    
    public function getRequestedScopes()
    {
        return $this->requestedScopes;
    }
    
    public function setRequestedScopes(array $requestedScopes)
    {
        $this->requestedScopes = $requestedScopes;
        return $this;
    }

    public function createRootData($resource)
    {
        return $this->createData($resource);
    }

    public function createData($resource, $scopeIdentifier = null, $parentScopeInstance = null)
    {
        $scopeInstance = new Scope($this, $scopeIdentifier);

        // Update scope history
        if ($parentScopeInstance !== null) {
            
            // This will be the new childs list of partents (parents parents, plus the parent)
            $scopeArray = $parentScopeInstance->getParentScopes();
            $scopeArray[] = $parentScopeInstance->getCurrentScope();

            $scopeInstance->setParentScopes($scopeArray);
        }

        // if's n shit
        if ($resource instanceof ItemResource) {
            $data = $this->processItem($scopeInstance, $resource);
        } elseif ($resource instanceof CollectionResource) {
            $data = $this->processCollection($scopeInstance, $resource);
        } elseif ($resource instanceof PaginatorResource) {
            $data = $this->processPaginator($scopeInstance, $resource);
        } else {
            throw new Exceptions('No idea what type of resource format this is');
        }

        // So, this data is the current scope data
        $scopeInstance->setCurrentData($data);

        return $scopeInstance;
    }

    protected function getCallableProcessor(ResourceInterface $resource)
    {
        $processor = $resource->getProcessor();

        if (is_callable($processor)) {
            return $processor;
        }

        return new $processor;
    }

    protected function fireProcessor($processor, Scope $scope, $data)
    {
        // Fire Main Processor
        if (is_callable($processor)) {
            $processedData = call_user_func($processor, $data);

        } else {
            $processedData = call_user_func(array($processor, 'process'), $data);

            // If its an object, process potential embeded resources
            if ($processor instanceof ProcessorAbstract) {
                $embededData = $processor->processEmbededResources($scope, $data);

                // Push the new embeds in with the main data
                $processedData = array_merge($processedData, $embededData);
            }
        }
        
        return $processedData;
    }


    protected function processItem($scope, ItemResource $resource)
    {
{'fraction_non_alphanumeric': 0.10124042320321051, 'fraction_numerical': 0.0, 'mean_word_length': 2.361741263028817, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '7234384', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1352, 'n_words': 353}