<commit_before><?php

namespace Layer\Data\Metadata\Query;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Reader;
use Doctrine\ORM\Mapping\ClassMetadata;
use Layer\Data\Metadata\QueryInterface;

abstract class PropertyAnnotationQuery implements QueryInterface {

	protected $reader;

	public function __construct(Reader $reader) {
		$this->reader = $reader;
		$this->initialize();
	}

	protected function initialize() {}

	public function getResult(ClassMetadata $classMetadata, array $options = []) {
		if(!isset($options['property'])) {
			throw new \InvalidArgumentException('The property option must be specified!');
		}
		$property = $classMetadata->getReflectionProperty($options['property']);
		$annotation = $this->reader->getPropertyAnnotation($property, $this->getAnnotationClass());
		return $this->getResultFromAnnotation($classMetadata, $annotation, $options);
	}

	abstract protected function getAnnotationClass();

	abstract protected function getResultFromAnnotation(ClassMetadata $classMetadata, $annotation, array $options);

}<commit_msg>Created reader getter<commit_after><?php

namespace Layer\Data\Metadata\Query;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Reader;
use Doctrine\ORM\Mapping\ClassMetadata;
use Layer\Data\Metadata\QueryInterface;

abstract class PropertyAnnotationQuery implements QueryInterface {

	private $reader;

	public function __construct(Reader $reader) {
		$this->reader = $reader;
		$this->initialize();
	}

	protected function initialize() {}

	public function getResult(ClassMetadata $classMetadata, array $options = []) {
		$this->checkProperty($options);
		$property = $classMetadata->getReflectionProperty($options['property']);
		$annotation = $this->getReader()->getPropertyAnnotation($property, $this->getAnnotationClass());
		return $this->getResultFromAnnotation($classMetadata, $annotation, $options);
	}

	protected function getReader() {
		return $this->reader;
	}

	protected function checkProperty(array $options) {
		if(!isset($options['property'])) {
			throw new \InvalidArgumentException('The property option must be specified!');
		}
	}

	abstract protected function getAnnotationClass();

	abstract protected function getResultFromAnnotation(ClassMetadata $classMetadata, $annotation, array $options);

}
{'fraction_non_alphanumeric': 0.12152332049636286, 'fraction_numerical': 0.0, 'mean_word_length': 6.8193979933110365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6196957', 'n_tokens_mistral': 631, 'n_tokens_neox': 593, 'n_words': 140}