<commit_before><?php
/**
 * HiPay Fullservice Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Apache 2.0 Licence
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * @copyright      Copyright (c) 2016 - HiPay
 * @license        http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0 Licence
 *
 */

namespace HiPay\FullserviceMagento\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Module\ResourceInterface;

/**
 * Main Helper class
 *
 * @package HiPay\FullserviceMagento
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2016 - HiPay
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0 Licence
 * @link https://github.com/hipay/hipay-fullservice-sdk-magento2
 */
class Data extends AbstractHelper
{

    /**
     *
     * @var \HiPay\FullserviceMagento\Model\RuleFactory $_ruleFactory
     */
    protected $ruleFactory;

    /**
     * @var \Magento\Framework\Module\ResourceInterface
     */
    protected $moduleResource;

    /**
     * @var ProductMetadataInterface
     */
    protected $productMetadata;

    public function __construct(
        Context $context,
        \HiPay\FullserviceMagento\Model\RuleFactory $ruleFactory,
        ResourceInterface $moduleResource,
        ProductMetadataInterface $productMetadata
    ) {
        parent::__construct($context);
        $this->ruleFactory = $ruleFactory;
        $this->moduleResource = $moduleResource;
        $this->productMetadata = $productMetadata;
    }

    /**
     *
     * @param bool $use3dSecure
     * @param int $config3dsRules
     * @param \Magento\Quote\Model\Quote $quote
     * @return int
     */
    public function is3dSecure($use3dSecure, $config3dsRules, $quote = null)
    {
        $params = 0;
        if ($use3dSecure > 0 && $quote === null) {
            $params = 1;
        } else {
            switch ((int)$use3dSecure) {
                case 1:
                    $params = 1;
                    break;
                case 2:
                case 3:
                    /** @var $rule Allopass_Hipay_Model_Rule **/
                    $rule = $this->_ruleFactory->create();
                    $rule->getResource()->load($rule, $config3dsRules);
                    if ($rule->getId() && $rule->validate($quote)) {
                        $params = 1;
                        //case for force 3ds if rules are validated
                        if ((int)$use3dSecure == 3) {
                            $params = 2;
                        }
                    }
                    break;
                case 4:
                    $params = 2;
                    break;
            }
        }
        return $params;
    }

    /**
     *
     * @param bool $allowUseOneclick Method config Data
     * @param int $filterOneclick Rule's id in configuration
     * @param \Magento\Quote\Model\Quote $quote
     * @return boolean
     */
    public function useOneclick($allowUseOneclick, $filterOneclick, $quote)
    {
        switch ((int)$allowUseOneclick) {
            case 0:
                return false;<commit_msg>Fix issue #119<commit_after><?php
/**
 * HiPay Fullservice Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Apache 2.0 Licence
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * @copyright      Copyright (c) 2016 - HiPay
 * @license        http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0 Licence
 *
 */

namespace HiPay\FullserviceMagento\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Module\ResourceInterface;

/**
 * Main Helper class
 *
 * @package HiPay\FullserviceMagento
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2016 - HiPay
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0 Licence
 * @link https://github.com/hipay/hipay-fullservice-sdk-magento2
 */
class Data extends AbstractHelper
{

    /**
     *
     * @var \HiPay\FullserviceMagento\Model\RuleFactory $ruleFactory
     */
    protected $ruleFactory;

    /**
     * @var \Magento\Framework\Module\ResourceInterface
     */
    protected $moduleResource;

    /**
     * @var ProductMetadataInterface
     */
    protected $productMetadata;

    public function __construct(
        Context $context,
        \HiPay\FullserviceMagento\Model\RuleFactory $ruleFactory,
        ResourceInterface $moduleResource,
        ProductMetadataInterface $productMetadata
    ) {
        parent::__construct($context);
        $this->ruleFactory = $ruleFactory;
        $this->moduleResource = $moduleResource;
        $this->productMetadata = $productMetadata;
    }

    /**
     *
     * @param bool $use3dSecure
     * @param int $config3dsRules
     * @param \Magento\Quote\Model\Quote $quote
     * @return int
     */
    public function is3dSecure($use3dSecure, $config3dsRules, $quote = null)
    {
        $params = 0;
        if ($use3dSecure > 0 && $quote === null) {
            $params = 1;
        } else {
            switch ((int)$use3dSecure) {
                case 1:
                    $params = 1;
                    break;
                case 2:
                case 3:
                    /** @var $rule Allopass_Hipay_Model_Rule * */
                    $rule = $this->ruleFactory->create();
                    $rule->getResource()->load($rule, $config3dsRules);
                    if ($rule->getId() && $rule->validate($quote)) {
                        $params = 1;
                        //case for force 3ds if rules are validated
                        if ((int)$use3dSecure == 3) {
                            $params = 2;
                        }
                    }
                    break;
                case 4:
                    $params = 2;
                    break;
            }
        }
        return $params;
    }

    /**
     *
     * @param bool $allowUseOneclick Method config Data
     * @param int $filterOneclick Rule's id in configuration
     * @param \Magento\Quote\Model\Quote $quote
     * @return boolean
     */
    public function useOneclick($allowUseOneclick, $filterOneclick, $quote)
    {
        switch ((int)$allowUseOneclick) {
            case 0:
                return false;
{'fraction_non_alphanumeric': 0.11203007518796992, 'fraction_numerical': 0.01368421052631579, 'mean_word_length': 1.8447390932420873, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, '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': '1015630', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1842, 'n_words': 427}