<commit_before><?php
/**
 * This file is part of the arhitector/jumper library.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author    <NAME> <<EMAIL>>
 *
 * @license   http://opensource.org/licenses/MIT MIT
 * @copyright Copyright (c) 2017 <NAME> <<EMAIL>>
 */
namespace Arhitector\Jumper\Format;

/**
 * Class FormatTrait.
 *
 * @package Arhitector\Jumper\Format
 */
trait FormatTrait
{
	
	/**
	 * @var float Duration value.
	 */
	protected $duration = 0.0;
	
	/**
	 * @var array IDv3 tags or other.
	 */<commit_msg>Добавлен статический метод фабрика FormatTrait::fromArray<commit_after><?php
/**
 * This file is part of the arhitector/jumper library.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author    <NAME> <<EMAIL>>
 *
 * @license   http://opensource.org/licenses/MIT MIT
 * @copyright Copyright (c) 2017 <NAME> <<EMAIL>>
 */
namespace Arhitector\Jumper\Format;

/**
 * Class FormatTrait.
 *
 * @package Arhitector\Jumper\Format
 */
trait FormatTrait
{
	
	/**
	 * Returns a new format instance.
	 *
	 * @param array $options
	 *
	 * @return static
	 */
	public static function fromArray(array $options)
	{
		$self = new static();
		
		foreach ($options as $option => $value)
		{
			$parameter = str_replace('_', '', 'set'.ucwords($option, '_'));
			
			if (method_exists($self, $parameter))
			{
				$self->{$parameter}($value);
			}
		}
		
		return $self;
	}
	
	/**
	 * @var float Duration value.
	 */
	protected $duration = 0.0;
	
	/**
	 * @var array IDv3 tags or other.
	 */
{'fraction_non_alphanumeric': 0.1436265709156194, 'fraction_numerical': 0.008378216636744464, 'mean_word_length': 3.18, 'pattern_counts': {'":': 0, '<': 17, '<?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': '4091134', 'n_tokens_mistral': 589, 'n_tokens_neox': 539, 'n_words': 158}