<commit_before><?php
namespace MD5BusterBundle\Services;

use Doctrine\ORM\EntityManager;
use Lsw\ApiCallerBundle\Call\HttpPostJson;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\ParameterBag;

/**
 * Class TemplatingService
 * @package MD5Buster\Services
 */
class MD5Service
{
    private $container;
    private $em;

    /**
     * @param Container $container
     * @param EntityManager $em
     */
    public function __construct( Container $container, EntityManager $em )
    {
        $this->container = $container;
        $this->em = $em;
    }

    /**
     * @param $securityCode
     * @return bool
     */
    public function googleRecaptchaSecurityCheck( $securityCode )
    {
        /** @noinspection PhpParamsInspection */
        $output = $this->container->get('api_caller')->call(
            new HttpPostJson(
                'https://www.google.com/recaptcha/api/siteverify',
                [
                    'secret' => $this->container->getParameter('recaptcha_secret_key'),
                    'response' => $securityCode
                ],
                true // as associative array
            )
        );
        if( array_key_exists( 'success', $output  ) && $output['success'] == true ){
            return true;
        } else {
            return false;
        }
    }

    /**
     * @param $string
     * @return string
     */
    private function safeText( $string )
    {
        return is_string( $string ) ? html_entity_decode( strip_tags( trim( $string ) ), ENT_HTML5 ) : $string;
    }

    /**<commit_msg>debug recaptcha<commit_after><?php
namespace MD5BusterBundle\Services;

use Doctrine\ORM\EntityManager;
use Lsw\ApiCallerBundle\Call\HttpPostJson;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\ParameterBag;

/**
 * Class TemplatingService
 * @package MD5Buster\Services
 */
class MD5Service
{
    private $container;
    private $em;

    /**
     * @param Container $container
     * @param EntityManager $em
     */
    public function __construct( Container $container, EntityManager $em )
    {
        $this->container = $container;
        $this->em = $em;
    }

    /**
     * @param $securityCode
     * @return bool
     */
    public function googleRecaptchaSecurityCheck( $securityCode )
    {
        /** @noinspection PhpParamsInspection */
        $output = $this->container->get('api_caller')->call(
            new HttpPostJson(
                'https://www.google.com/recaptcha/api/siteverify',
                [
                    'secret' => $this->container->getParameter('recaptcha_secret_key'),
                    'response' => $securityCode
                ],
                true // as associative array
            )
        );
        var_dump($output);die;
        if( array_key_exists( 'success', $output  ) && $output['success'] == true ){
            return true;
        } else {
            return false;
        }
    }

    /**
     * @param $string
     * @return string
     */
    private function safeText( $string )
    {
        return is_string( $string ) ? html_entity_decode( strip_tags( trim( $string ) ), ENT_HTML5 ) : $string;
    }

    /**
{'fraction_non_alphanumeric': 0.12272024729520865, 'fraction_numerical': 0.002472952086553323, 'mean_word_length': 2.084842707340324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2879432', 'n_tokens_mistral': 932, 'n_tokens_neox': 914, 'n_words': 180}