<commit_before><?php
/**
 * @license   http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
 * @copyright Copyright (c) 2015 <NAME> (http://julienguittard.com)
 */

namespace Zoho\Subscriptions\Hydrator\Strategy;

use Zend\Stdlib\Hydrator\ClassMethods;
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;
use Zoho\Subscriptions\Entity\Address as AddressEntity;

/**
 * Class AddressStrategy
 *
 * @package Zoho\Subscriptions\Hydrator\Strategy
 */
class AddressStrategy implements StrategyInterface
{
    /**
     * Converts the given value so that it can be extracted by the hydrator.
     *
     * @param mixed $value The original value.
     * @return mixed Returns the value that should be extracted.
     */
    public function extract($value)
    {
        if (!is_array($value)) {
            return $value;
        }
        $hydrator = new ClassMethods(true);
        return $hydrator->hydrate($value, new AddressEntity());
    }

    /**
     * Converts the given value so that it can be hydrated by the hydrator.<commit_msg>fixed extract method of AddressStrategy<commit_after><?php
/**
 * @license   http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
 * @copyright Copyright (c) 2015 <NAME> (http://julienguittard.com)
 */

namespace Zoho\Subscriptions\Hydrator\Strategy;

use Zend\Stdlib\Hydrator\ClassMethods;
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;
use Zoho\Subscriptions\Entity\Address as AddressEntity;

/**
 * Class AddressStrategy
 *
 * @package Zoho\Subscriptions\Hydrator\Strategy
 */
class AddressStrategy implements StrategyInterface
{
    /**
     * Converts the given value so that it can be extracted by the hydrator.
     *
     * @param mixed $value The original value.
     * @return mixed Returns the value that should be extracted.
     */
    public function extract($value)
    {
        if (!$value instanceof AddressEntity) {
            throw new \InvalidArgumentException("Invalid address.");
        }

        $hydrator = new ClassMethods(false);
        return $hydrator->extract($value);
    }

    /**
     * Converts the given value so that it can be hydrated by the hydrator.
{'fraction_non_alphanumeric': 0.10644257703081232, 'fraction_numerical': 0.0056022408963585435, 'mean_word_length': 3.169260700389105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4320550', 'n_tokens_mistral': 633, 'n_tokens_neox': 604, 'n_words': 171}