1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/applications/differential/storage/DifferentialReviewer.php
Joshua Spence 97a8700e45 Rename PHIDType classes
Summary: Ref T5655. Rename `PhabricatorPHIDType` subclasses for clarity (see discussion in D9839). I'm not too keen on some of the resulting class names, so feel free to suggest alternatives.

Test Plan: Ran unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, hach-que

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D9986
2014-07-24 08:05:46 +10:00

56 lines
1.4 KiB
PHP

<?php
final class DifferentialReviewer {
private $reviewerPHID;
private $status;
private $diffID;
private $authority = array();
public function __construct($reviewer_phid, array $edge_data) {
$this->reviewerPHID = $reviewer_phid;
$this->status = idx($edge_data, 'status');
$this->diffID = idx($edge_data, 'diff');
}
public function getReviewerPHID() {
return $this->reviewerPHID;
}
public function getStatus() {
return $this->status;
}
public function getDiffID() {
return $this->diffID;
}
public function isUser() {
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
return (phid_get_type($this->getReviewerPHID()) == $user_type);
}
public function attachAuthority(PhabricatorUser $user, $has_authority) {
$this->authority[$user->getPHID()] = $has_authority;
return $this;
}
public function hasAuthority(PhabricatorUser $viewer) {
// It would be nice to use assertAttachedKey() here, but we don't extend
// PhabricatorLiskDAO, and faking that seems sketchy.
$viewer_phid = $viewer->getPHID();
if (!array_key_exists($viewer_phid, $this->authority)) {
throw new Exception('You must attachAuthority() first!');
}
return $this->authority[$viewer_phid];
}
public function getEdgeData() {
return array(
'status' => $this->status,
'diffID' => $this->diffID,
);
}
}