<commit_before><?php

/**
 * This file is part of the Hayttp package.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2017
 * @license MIT
 */

namespace Hayttp\Traits;

use Closure;
use BadMethodCallException;

/**
 * Make a class dynamically extendable.
 */
trait Extendable
{
    /**
     * @var array
     */
    protected static $extensions = [];

    public static function hasExtension($methodName)
    {
        return isset(static::$extensions[$methodName]);
    }


    /**
     * Add a method to the class.
     *
     * @param string   $methodName
     * @param callable $callable
     *
     * @return $this
     */
    public static function extend(string $methodName, callable $callable)
    {
        static::$extensions[$methodName] = $callable;
    }

    /**
     * Mix in all the public methods of an object.
     *
     * @param object $object
     *
     * @return $this
     */
    public static function mixin(object $object)
    {
        $refObject = new ReflectionObject($object);

        $methods = $refObject->getMethods(ReflectionMethod::IS_PUBLIC);<commit_msg>Docblock and return value for hasExtension()<commit_after><?php

/**
 * This file is part of the Hayttp package.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2017
 * @license MIT
 */

namespace Hayttp\Traits;

use Closure;
use BadMethodCallException;

/**
 * Make a class dynamically extendable.
 */
trait Extendable
{
    /**
     * @var array
     */
    protected static $extensions = [];

    /**
     * Has this class been extended with a given method?
     *
     * @param string $methodName The name of the method
     *
     * @return bool
     */
    public static function hasExtension($methodName) : bool
    {
        return isset(static::$extensions[$methodName]);
    }


    /**
     * Add a method to the class.
     *
     * @param string   $methodName
     * @param callable $callable
     *
     * @return $this
     */
    public static function extend(string $methodName, callable $callable)
    {
        static::$extensions[$methodName] = $callable;
    }

    /**
     * Mix in all the public methods of an object.
     *
     * @param object $object
     *
     * @return $this
     */
    public static function mixin(object $object)
    {
        $refObject = new ReflectionObject($object);

        $methods = $refObject->getMethods(ReflectionMethod::IS_PUBLIC);
{'fraction_non_alphanumeric': 0.11811685582177385, 'fraction_numerical': 0.003362757461118117, 'mean_word_length': 2.4, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3483846', 'n_tokens_mistral': 712, 'n_tokens_neox': 697, 'n_words': 198}