<commit_before><?php

namespace Neochic\SlimTools\Http;

use \Slim\Http\Response as SlimResponse;
use \JMS\Serializer\SerializationContext;
use \Neochic\SlimTools\Serializer\SerializationContextFactory;


class Response extends SlimResponse {
	protected $serializationContext = null;
	protected $viewData = null;
	protected $skipViewRendering = false;

	/**
	 * @return SerializationContext
	 */
	public function getSerializationContext() : SerializationContext {
		if(!$this->serializationContext) {
			$serializationContextFactory = new SerializationContextFactory();
			return $serializationContextFactory->createSerializationContext(array('everyone'));
		}

		return $this->serializationContext;
	}

	/**
	 * @param SerializationContext $context
	 */
	public function setSerializationContext( SerializationContext $context ) {
		$this->serializationContext = $context;
	}

	/**
	 * @return null
	 */
	public function getViewData() {
		return $this->viewData;
	}

	/**
	 * @param null $data
	 */
	public function setViewData( $data ) {
		$this->viewData = $data;
	}

	/**<commit_msg>* added helper function to response to make it more easy to add group serialization context<commit_after><?php

namespace Neochic\SlimTools\Http;

use \Slim\Http\Response as SlimResponse;
use \JMS\Serializer\SerializationContext;
use \Neochic\SlimTools\Serializer\SerializationContextFactory;


class Response extends SlimResponse {
	protected $serializationContext = null;
	protected $viewData = null;
	protected $skipViewRendering = false;

	/**
	 * @return SerializationContext
	 */
	public function getSerializationContext(): SerializationContext {
		if ( ! $this->serializationContext ) {
			$serializationContextFactory = new SerializationContextFactory();

			return $serializationContextFactory->createSerializationContext( array( 'everyone' ) );
		}

		return $this->serializationContext;
	}

	/**
	 * @param SerializationContext $context
	 */
	public function setSerializationContext( SerializationContext $context ) {
		$this->serializationContext = $context;
	}

	/**
	 * @param array $groups
	 */
	public function setSerializationContextGroups( array $groups ) {
		$serializationContextFactory = new SerializationContextFactory();
		$context                     = $serializationContextFactory->createSerializationContext( $groups );
		$this->setSerializationContext( $context );
	}

	/**
	 * @return null
	 */
	public function getViewData() {
		return $this->viewData;
	}

	/**
	 * @param null $data
	 */
	public function setViewData( $data ) {
		$this->viewData = $data;
	}

	/**
{'fraction_non_alphanumeric': 0.11128344319503683, 'fraction_numerical': 0.0, 'mean_word_length': 4.682819383259912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '621268', 'n_tokens_mistral': 760, 'n_tokens_neox': 718, 'n_words': 162}