Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/DiffusionResolveUserQuery.php
<?php | <?php | ||||
/** | /** | ||||
* Resolve an author or committer name, like | * Resolve an author or committer name, like | ||||
* `"Abraham Lincoln <alincoln@logcab.in>"`, into a valid Phabricator user | * `"Abraham Lincoln <alincoln@logcab.in>"`, into a valid Phabricator user | ||||
* account, like `@alincoln`. | * account, like `@alincoln`. | ||||
*/ | */ | ||||
final class DiffusionResolveUserQuery extends Phobject { | final class DiffusionResolveUserQuery extends Phobject { | ||||
private $name; | private $name; | ||||
/** | |||||
* @param string $name | |||||
* | |||||
* @return self | |||||
*/ | |||||
public function withName($name) { | public function withName($name) { | ||||
$this->name = $name; | $this->name = $name; | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return string|null | |||||
*/ | |||||
public function execute() { | public function execute() { | ||||
return $this->findUserPHID($this->name); | return $this->findUserPHID($this->name); | ||||
} | } | ||||
private function findUserPHID($user_name) { | private function findUserPHID($user_name) { | ||||
if (!strlen($user_name)) { | if (!strlen($user_name)) { | ||||
return null; | return null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0