1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2019 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17declare(strict_types=1); 18 19namespace Fisharebest\Webtrees\Statistics\Repository; 20 21use Fisharebest\Webtrees\Services\UserService; 22use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ContactRepositoryInterface; 23use Fisharebest\Webtrees\Tree; 24use Fisharebest\Webtrees\User; 25 26/** 27 * A repository providing methods for contact related statistics. 28 */ 29class ContactRepository implements ContactRepositoryInterface 30{ 31 /** 32 * @var Tree 33 */ 34 private $tree; 35 /** 36 * @var UserService 37 */ 38 private $user_service; 39 40 /** 41 * Constructor. 42 * 43 * @param Tree $tree 44 * @param UserService $user_service 45 */ 46 public function __construct(Tree $tree, UserService $user_service) 47 { 48 $this->tree = $tree; 49 $this->user_service = $user_service; 50 } 51 52 /** 53 * @inheritDoc 54 */ 55 public function contactWebmaster(): string 56 { 57 $user_id = (int) $this->tree->getPreference('WEBMASTER_USER_ID'); 58 $user = $this->user_service->find($user_id); 59 60 if ($user instanceof User) { 61 return $this->user_service->contactLink($user); 62 } 63 64 return ''; 65 } 66 67 /** 68 * @inheritDoc 69 */ 70 public function contactGedcom(): string 71 { 72 $user_id = (int) $this->tree->getPreference('CONTACT_USER_ID'); 73 $user = $this->user_service->find($user_id); 74 75 if ($user instanceof User) { 76 return $this->user_service->contactLink($user); 77 } 78 79 return ''; 80 } 81} 82