<commit_before><?php
/**
 * Main webhook class, which can be used singularly or to return a service hook like GitHub, GitLab etc.
 *
 * @category   API
 * @package    webhook-api
 * @author     <NAME>
 * @copyright  2017
 * @license    https://github.com/jakobjohansson/webhook-api/blob/master/LICENSE.txt MIT-License
 */
class Hook {

    /**
     * Webhook headers
     * @var Array
     */
    protected $headers;

    /**
     * Content-Type header
     * (application/json, application/x-www-form-urlencoded etc)
     * @var String
     */
    protected $contentType;

    /**
     * The transmission payload encoded in JSON
     * @var Object
     */
    protected $payload = null;

    /**
     * Final output string, ready to be used.
     * @var String
     */
    public $output = null;

    /**
     * Messages from the API used for trouble shooting or status texts
     * @var Array
     */
    public $apiMessages = [];

    /**
     * Fetch headers and payload
     * @return void
     */
    public function __construct() {
        $this->fetchHeaders();
        $this->fetchPayload();
    }

    /**
     * Returns the $apiMessages
     * @return Array APIMessages
     */
    public function getApiMessages() {
        return $this->apiMessages();
    }

    /**
     * Fetches all the webhook headers and sets them as object properties
     * @return void
     */
    protected function fetchHeaders() {
        $this->headers = apache_request_headers();
        $this->contentType = isset($this->headers['content-type']) ?: null;
    }

    /**
     * Fetches the payload from the webhook.
     * @return void
     */
    protected function fetchPayload() {
        switch ($this->contentType) {
            case 'application/json':
                $this->payload = json_decode(file_get_contents('php://input'));
            break;
            case 'application/x-www-form-urlencoded':
                $this->payload = $_POST['payload'];
            break;
            default:
                $this->apiMessages[] = "Invalid Content Type";
        }
    }

    /**<commit_msg>fixed issues #4 #5 #7<commit_after><?php
/**
 * Main webhook class, which can be used singularly or to return a service hook like GitHub, GitLab etc.
 *
 * @category   API
 * @package    webhook-api
 * @author     <NAME>
 * @copyright  2017
 * @license    https://github.com/jakobjohansson/webhook-api/blob/master/LICENSE.txt MIT-License
 */
class Hook {

    /**
     * Webhook headers
     * @var Array
     */
    public $headers;

    /**
     * Content-Type header
     * (application/json, application/x-www-form-urlencoded etc)
     * @var String
     */
    protected $contentType;

    /**
     * The transmission payload encoded in JSON
     * @var Object
     */
    public $payload = null;

    /**
     * Final output string, ready to be used.
     * @var String
     */
    public $output = null;

    /**
     * Messages from the API used for trouble shooting or status texts
     * @var Array
     */
    protected $apiMessages = [];

    /**
     * Fetch headers and payload
     * @return void
     */
    public function __construct() {
        $this->fetchHeaders();
        $this->fetchPayload();
    }

    /**
     * Returns the $apiMessages
     * @return Array APIMessages
     */
    public function getApiMessages() {
        return $this->apiMessages;
    }

    /**
     * Fetches all the webhook headers and sets them as object properties
     * @return void
     */
    protected function fetchHeaders() {
        $this->headers = apache_request_headers();
        $this->contentType = isset($this->headers['Content-Type']) ?: null;
    }

    /**
     * Fetches the payload from the webhook.
     * @return void
     */
    protected function fetchPayload() {
        switch ($this->contentType) {
            case 'application/json':
                $this->payload = json_decode(file_get_contents('php://input'));
            break;
            case 'application/x-www-form-urlencoded':
                $this->payload = $_POST['payload'];
            break;
            default:
                $this->apiMessages[] = "Invalid Content Type";
        }
    }

    /**
{'fraction_non_alphanumeric': 0.12276519666269368, 'fraction_numerical': 0.002622169249106079, 'mean_word_length': 1.944561403508772, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '6088578', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1157, 'n_words': 316}