<commit_before><?php
namespace watoki\factory\providers;

use watoki\factory\Factory;

class DefaultProvider extends MinimalProvider {

    private $propertyFilter;

    private $annotationFilter;

    private $injectionMethod = 'inject';

    function __construct(Factory $factory) {
        parent::__construct($factory);


        $this->annotationFilter = function ($annotation) {
            return strpos($annotation, '<-') !== false;
        };
        $this->propertyFilter = function (\ReflectionProperty $property) {
            return strpos($property->getDocComment(), '<-') !== false;
        };
    }

    public function provide($class, array $args = array()) {
        $instance = parent::provide($class, $args);

        if ($this->injectionMethod && method_exists($instance, $this->injectionMethod)) {
            $this->injector->injectMethod($instance, $this->injectionMethod);
        }

        $this->injector->injectProperties($instance, $this->propertyFilter);

        $this->injector->injectPropertyAnnotations($instance, $this->annotationFilter);

        return $instance;
    }

    /**
     * @param callable $filter
     */
    public function setAnnotationFilter($filter) {
        $this->annotationFilter = $filter;
    }

    /**
     * @return callable
     */
    public function getAnnotationFilter() {
        return $this->annotationFilter;
    }

    /**
     * @return callable
     */
    public function getPropertyFilter() {
        return $this->propertyFilter;
    }

    /**
     * @param callable $propertyFilter
     */
    public function setPropertyFilter($propertyFilter) {
        $this->propertyFilter = $propertyFilter;
    }

    /**
     * @param string $injectionMethod
     */
    public function setInjectionMethod($injectionMethod) {
        $this->injectionMethod = $injectionMethod;
    }
}<commit_msg>Extracted injection token to constant<commit_after><?php
namespace watoki\factory\providers;

use watoki\factory\Factory;

class DefaultProvider extends MinimalProvider {

    const INJECTION_TOKEN = '<-';

    private $propertyFilter;

    private $annotationFilter;

    private $injectionMethod = 'inject';

    function __construct(Factory $factory) {
        parent::__construct($factory);

        $this->annotationFilter = function ($annotation) {
            return strpos($annotation, DefaultProvider::INJECTION_TOKEN) !== false;
        };

        $this->propertyFilter = function (\ReflectionProperty $property) {
            return strpos($property->getDocComment(), DefaultProvider::INJECTION_TOKEN) !== false;
        };
    }

    public function provide($class, array $args = array()) {
        $instance = parent::provide($class, $args);

        if ($this->injectionMethod && method_exists($instance, $this->injectionMethod)) {
            $this->injector->injectMethod($instance, $this->injectionMethod);
        }

        $this->injector->injectProperties($instance, $this->getPropertyFilter());

        $this->injector->injectPropertyAnnotations($instance, $this->getAnnotationFilter());

        return $instance;
    }

    /**
     * @param callable $filter
     */
    public function setAnnotationFilter($filter) {
        $this->annotationFilter = $filter;
    }

    /**
     * @return callable
     */
    public function getAnnotationFilter() {
        return $this->annotationFilter;
    }

    /**
     * @return callable
     */
    public function getPropertyFilter() {
        return $this->propertyFilter;
    }

    /**
     * @param callable $propertyFilter
     */
    public function setPropertyFilter($propertyFilter) {
        $this->propertyFilter = $propertyFilter;
    }

    /**
     * @param string $injectionMethod
     */
    public function setInjectionMethod($injectionMethod) {
        $this->injectionMethod = $injectionMethod;
    }
}
{'fraction_non_alphanumeric': 0.12911589318122893, 'fraction_numerical': 0.0, 'mean_word_length': 2.831181727904667, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 41, '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': '5545', 'n_tokens_mistral': 1027, 'n_tokens_neox': 977, 'n_words': 192}