/** * Get default values from different sources * * - github organization * - github user * - git user * - file owner * * @return array */ public function getDefaults() { $defaults = []; $origin = $this->gitConfig->getOrigin(); if (null !== $origin) { $response = $this->github->get("/repos/{$origin}"); $repo = json_decode($response->getBody(), true); if (isset($repo['organization'])) { $response = $this->github->get("/orgs/{$repo['organization']['login']}"); $organizaion = json_decode($response->getBody(), true); $defaults[] = $organizaion['name']; } $response = $this->github->get("/users/{$repo['owner']['login']}"); $owner = json_decode($response->getBody(), true); $defaults[] = $owner['name']; } $defaults[] = $this->gitConfig->get('user.name'); $defaults[] = get_current_user(); return array_values(array_unique(array_filter($defaults))); }
/** * @return string */ public function getDefault() { return $this->gitConfig->get('user.name'); }