<commit_before><?
class ImageModificator extends DbAccessor
{
	protected $config;
	
	const TBL_CROP_SETTINGS = 'image_crop_settings';
	
	const ACTION_CROP = 'crop';
	const ACTION_RESIZE = 'resize';
	const ACTION_STAMP = 'stamp';
	
	public function __construct(Config $config, $dbInstanceKey = null){
		parent::__construct($dbInstanceKey);
		$this->config = $config;
	}
	
	
	/**
	 * Make modifications on given Image object accrding to config
	 * 
	 * @param Image $image
	 * @param string $modelName
	 * @throws ImageModificatorException
	 * @throws InvalidArgumentException
	 */
	public function modify(Image $image, $modelName){
		if(empty($image->fileName)){
			throw new ImageModificatorException("Image is not initialized!");
		}
		
		if(!isset($this->config->imageModels->$modelName)){
			throw new InvalidArgumentException("There is no such image model with name $modelName");
		}
		
		foreach($this->config->imageModels->$modelName->actions as $actionName => $actionConfig){
			switch ($actionName){
				case self::ACTION_CROP:
					$this->cropImage($image, $modelName, $actionConfig);
					break;
				case self::ACTION_RESIZE:
					$this->resizeImage($image, $actionConfig);
					break;
				case self::ACTION_STAMP:
					$this->stampImage($image, $actionConfig);
					break;
			}
		}
	}
	<commit_msg>Support for custom actions config in ImageModificator<commit_after><?
class ImageModificator extends DbAccessor
{
	protected $config;
	
	const TBL_CROP_SETTINGS = 'image_crop_settings';
	
	const ACTION_CROP = 'crop';
	const ACTION_RESIZE = 'resize';
	const ACTION_STAMP = 'stamp';
	
	public function __construct(Config $config, $dbInstanceKey = null){
		parent::__construct($dbInstanceKey);
		$this->config = $config;
	}
	
	
	/**
	 * Make modifications on given Image object accrding to config
	 * 
	 * @param Image $image
	 * @param string $modelName
	 * @throws ImageModificatorException
	 * @throws InvalidArgumentException
	 */
	public function modify(Image $image, $modelName, Config $customActionsConfig = null){
		if(empty($image->fileName)){
			throw new ImageModificatorException("Image is not initialized!");
		}
		
		$config = null;
		if($customActionsConfig != null){
			$config = $customActionsConfig;
		}
		else{
			if(!isset($this->config->imageModels->$modelName)){
				throw new InvalidArgumentException("There is no such image model with name $modelName");
			}
			
			$config = $this->config->imageModels->$modelName->actions;
		}
		
		
		
		foreach($config as $actionName => $actionConfig){
			switch ($actionName){
				case self::ACTION_CROP:
					$this->cropImage($image, $modelName, $actionConfig);
					break;
				case self::ACTION_RESIZE:
					$this->resizeImage($image, $actionConfig);
					break;
				case self::ACTION_STAMP:
					$this->stampImage($image, $actionConfig);
					break;
			}
		}
	}
	
{'fraction_non_alphanumeric': 0.12667607621736063, 'fraction_numerical': 0.0, 'mean_word_length': 4.279329608938547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '825462', 'n_tokens_mistral': 1009, 'n_tokens_neox': 844, 'n_words': 204}