<commit_before><?php
/*
 * Copyright (c) 2013, <NAME>  <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

namespace Smalldb\StateMachine;

/**
 * Simple testing machine implementation. Uses array to store all data.
 */
class ArrayMachine extends AbstractMachine
{
	private $machine_definition;

	/**
	 * Data storage for all state machines
	 */
	protected $properties = array();


	/**
	 * Define state machine using $machine_definition.
	 */
	public function initializeMachine($args)
	{
		$this->states  = $args['states'];
		$this->actions = $args['actions'];
		$this->state_groups = (array) @ $args['state_groups'];
	}


	/**
	 * Reflection: Describe ID (primary key).
	 */
	public function describeId()
	{
		return array('id' => 'string');
	}


	/**
	 * Returns true if user has required permissions.
	 */
	protected function checkPermissions($permissions, $id)
	{
		return true;
	}


	/**
	 * Adds conditions to enforce read permissions to query object.
	 */
	protected function addPermissionsCondition($query)
	{
	}


	/**
	 * Get current state of state machine.
	 */
	public function getState($id)
	{
		if ($id === null) {
			return '';
		} else {
			return @ $this->properties[$id]['state'];
		}
	}<commit_msg>Fix ArrayMachine<commit_after><?php
/*
 * Copyright (c) 2013, <NAME>  <<EMAIL>-doe.net>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

namespace Smalldb\StateMachine;

/**
 * Simple testing machine implementation. Uses array to store all data.
 */
class ArrayMachine extends AbstractMachine
{
	private $machine_definition;

	/**
	 * Data storage for all state machines
	 */
	protected $properties = array();


	/**
	 * Define state machine using $machine_definition.
	 */
	public function initializeMachine($args)
	{
		$this->states  = $args['states'];
		$this->actions = $args['actions'];
		$this->properties = (array) @ $args['properties'];
		$this->state_groups = (array) @ $args['state_groups'];
	}


	/**
	 * Reflection: Describe ID (primary key).
	 */
	public function describeId()
	{
		return array('id');
	}


	/**
	 * Returns true if user has required permissions.
	 */
	protected function checkPermissions($permissions, $id)
	{
		return true;
	}


	/**
	 * Adds conditions to enforce read permissions to query object.
	 */
	protected function addPermissionsCondition($query)
	{
	}


	/**
	 * Get current state of state machine.
	 */
	public function getState($id)
	{
		if ($id === null) {
			return '';
		} else {
			return @ $this->properties[$id]['state'];
		}
	}
{'fraction_non_alphanumeric': 0.12358597285067874, 'fraction_numerical': 0.004524886877828055, 'mean_word_length': 3.5579896907216493, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '651827', 'n_tokens_mistral': 1068, 'n_tokens_neox': 992, 'n_words': 359}