예제 #1
0
 /**
  * @param array $data
  * @return self
  */
 public static function fromArray(array $data)
 {
     $issue = new self($data['number']);
     $issue->author = $data['user']['login'];
     $issue->open = $data['state'] === self::STATE_OPEN;
     $openingDate = new DateTime($data['created_at']);
     if (!$issue->open) {
         $endDate = new DateTime($data['closed_at']);
     } else {
         $endDate = new DateTime();
     }
     $issue->openedFor = TimeInterval::from($endDate, $openingDate);
     return $issue;
 }
예제 #2
0
 /**
  * @param array $data
  * @return self
  */
 public static function fromArray(array $data)
 {
     $issue = new self($data['number']);
     $issue->author = $data['user']['login'];
     $issue->open = $data['state'] === self::STATE_OPEN;
     $issue->openedAt = new DateTime($data['created_at']);
     if (!$issue->open) {
         $endDate = new DateTime($data['closed_at']);
     } else {
         $endDate = new DateTime();
     }
     $issue->openedFor = TimeInterval::from($endDate, $issue->openedAt);
     $labels = [];
     foreach ($data['labels'] as $dataLabel) {
         $labels[] = $dataLabel['name'];
     }
     $issue->labels = $labels;
     return $issue;
 }