Example #1
0
 function __construct($json)
 {
     $this->payload_type = 0;
     $this->priv_json = json_decode($json, true);
     if ($this->priv_json === null) {
         die("Unable to decode: " . $json);
     }
     if (array_key_exists("sender", $this->priv_json)) {
         $this->sender = new GitHub_SenderInfo($this->priv_json['sender']);
     }
     $this->repo_name = $this->priv_json['repository']['full_name'];
     if (array_key_exists("ref", $this->priv_json)) {
         // get a name of branch this is about
         $branch = $this->priv_json['ref'];
         if (GitHub::startsWith($branch, "refs/heads/")) {
             $branch = substr($branch, 11);
         }
         $this->repo_branch = $branch;
     }
     $action = "unknown";
     if (array_key_exists("action", $this->priv_json)) {
         $action = $this->priv_json['action'];
     }
     if ($action == "opened") {
         $this->payload_type = 2;
     } else {
         if ($action == "created") {
             $this->payload_type = 3;
         } else {
             if ($action == "closed") {
                 $this->payload_type = 4;
             } else {
                 if (array_key_exists("commits", $this->priv_json)) {
                     $this->payload_type = 1;
                 }
             }
         }
     }
     $this->process_msgs();
 }