<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Danny
 * Date: 15/06/2017
 * Time: 06:37 PM
 */

namespace App\Http\Controllers;


use App\Libraries\BitbucketNotification;
use App\Libraries\GithubNotification;
use App\VersionControlSystem;
use Illuminate\Http\Request;
use Illuminate\Notifications\Notifiable;

class NotifierController
{
    use Notifiable;

    public $notification;

    /**
     * Determine which VCS use to send the notification
     *
     * @param Request $request
     */
    public function index(Request $request)
    {
        $site = $request->header('User-Agent');
        $site = explode("/", $site)[0];

        $vcs = VersionControlSystem::where("user_agent", "LIKE", $site)->first();
        if (!$vcs) return;

        if ($vcs->name == "Github") {
            new GithubNotification($request);
        } else if ($vcs->name == "Bitbucket") {
            // Only 'pullrequest:created' action is supported at this moment
            $validAction = $request->header("X-Event-Key") == "pullrequest:created";
            if ($validAction) {
                new BitbucketNotification($request);
            } else {
                echo "Not a valid action. Only 'pullrequest:created' action is supported at this moment.\n";
            }
        }

        echo "Done With " . $vcs->name;<commit_msg>Remove bitbucket action validation<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Danny
 * Date: 15/06/2017
 * Time: 06:37 PM
 */

namespace App\Http\Controllers;


use App\Libraries\BitbucketNotification;
use App\Libraries\GithubNotification;
use App\VersionControlSystem;
use Illuminate\Http\Request;
use Illuminate\Notifications\Notifiable;
use function in_array;

class NotifierController
{
    use Notifiable;

    public $notification;

    /**
     * Determine which VCS use to send the notification
     *
     * @param Request $request
     */
    public function index(Request $request)
    {
        $site = $request->header('User-Agent');
        $site = explode("/", $site)[0];

        $vcs = VersionControlSystem::where("user_agent", "LIKE", $site)->first();
        if (!$vcs) return;

        if ($vcs->name == "Github") {
            new GithubNotification($request);
        } else if ($vcs->name == "Bitbucket") {
            new BitbucketNotification($request);
        }

        echo "Everything went well with " . $vcs->name . ".";
{'fraction_non_alphanumeric': 0.13352745424292845, 'fraction_numerical': 0.010815307820299502, 'mean_word_length': 2.6494688922610017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '1448684', 'n_tokens_mistral': 714, 'n_tokens_neox': 691, 'n_words': 176}