<commit_before><?php
/**
 * Webiny Platform (http://www.webiny.com/)
 *
 * @copyright Copyright (c) 2009-2014 Webiny LTD. (http://www.webiny.com/)
 * @license   http://www.webiny.com/platform/license
 */

namespace Apps\Core\Php\Dispatchers;

use Apps\Core\Php\DevTools\DevToolsTrait;
use Webiny\Component\StdLib\StdLibTrait;
use Webiny\Component\Validation\Validation;
use Webiny\Component\Validation\ValidationException;

/**
 * Class ApiMethod
 *
 * This class is used when we want to expose class or service method to the API
 *
 * @package Apps\Core\Php\Dispatchers
 */
class ApiMethod
{
    use ParamsInjectorTrait, StdLibTrait, DevToolsTrait;

    private $httpMethod;
    private $methodName;
    private $callbacks = [];
    private $bodyValidators;

    function __construct($httpMethod, $methodName, $callable = null)
    {
        $this->httpMethod = $httpMethod;
        $this->methodName = $methodName;
        if ($callable) {
            $this->callbacks = [$callable];
        }
    }

    public function __invoke($params, $bindTo = null)
    {
        if (!$params) {
            $params = [];
        }

        if ($this->httpMethod === 'post' || $this->httpMethod === 'patch') {
            $this->validateBody($this->wRequest()->getRequestData());
        }<commit_msg>Validation check<commit_after><?php
/**
 * Webiny Platform (http://www.webiny.com/)
 *
 * @copyright Copyright (c) 2009-2014 Webiny LTD. (http://www.webiny.com/)
 * @license   http://www.webiny.com/platform/license
 */

namespace Apps\Core\Php\Dispatchers;

use Apps\Core\Php\DevTools\DevToolsTrait;
use Webiny\Component\StdLib\StdLibTrait;
use Webiny\Component\Validation\Validation;
use Webiny\Component\Validation\ValidationException;

/**
 * Class ApiMethod
 *
 * This class is used when we want to expose class or service method to the API
 *
 * @package Apps\Core\Php\Dispatchers
 */
class ApiMethod
{
    use ParamsInjectorTrait, StdLibTrait, DevToolsTrait;

    private $httpMethod;
    private $methodName;
    private $callbacks = [];
    private $bodyValidators;

    function __construct($httpMethod, $methodName, $callable = null)
    {
        $this->httpMethod = $httpMethod;
        $this->methodName = $methodName;
        if ($callable) {
            $this->callbacks = [$callable];
        }
    }

    public function __invoke($params, $bindTo = null)
    {
        if (!$params) {
            $params = [];
        }

        if (($this->httpMethod === 'post' || $this->httpMethod === 'patch') && count($this->bodyValidators)) {
            $this->validateBody($this->wRequest()->getRequestData());
        }
{'fraction_non_alphanumeric': 0.14307516215185043, 'fraction_numerical': 0.006104540251812286, 'mean_word_length': 2.9787556904400607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, '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': '7293453', 'n_tokens_mistral': 828, 'n_tokens_neox': 826, 'n_words': 170}