Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Author class.
  19   *
  20   * @package    mod_forum
  21   * @copyright  2019 Ryan Wyllie <ryan@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace mod_forum\local\entities;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Author class.
  31   *
  32   * @copyright  2019 Ryan Wyllie <ryan@moodle.com>
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class author {
  36      /** @var int $id ID */
  37      private $id;
  38      /** @var int $pictureitemid Picture item id */
  39      private $pictureitemid;
  40      /** @var string $firstname First name */
  41      private $firstname;
  42      /** @var string $lastname Last name */
  43      private $lastname;
  44      /** @var string $fullname Full name */
  45      private $fullname;
  46      /** @var string $email Email */
  47      private $email;
  48      /** @var bool $deleted Deleted */
  49      private $deleted;
  50      /** @var string $middlename Middle name */
  51      private $middlename;
  52      /** @var string $firstnamephonetic Phonetic spelling of first name */
  53      private $firstnamephonetic;
  54      /** @var string $lastnamephonetic Phonetic spelling of last name */
  55      private $lastnamephonetic;
  56      /** @var string $alternatename Altername name */
  57      private $alternatename;
  58      /** @var string $imagealt Image alt */
  59      private $imagealt;
  60  
  61      /**
  62       * Constructor.
  63       *
  64       * @param int $id ID
  65       * @param int $pictureitemid Picture item id
  66       * @param string $firstname First name
  67       * @param string $lastname Last name
  68       * @param string $fullname Full name
  69       * @param string $email Email
  70       * @param string|null $middlename Middle name
  71       * @param string|null $firstnamephonetic Phonetic spelling of first name
  72       * @param string|null $lastnamephonetic Phonetic spelling of last name
  73       * @param string|null $alternatename Altername name
  74       * @param string|null $imagealt Image alt
  75       */
  76      public function __construct(
  77          int $id,
  78          int $pictureitemid,
  79          string $firstname,
  80          string $lastname,
  81          string $fullname,
  82          string $email,
  83          bool $deleted,
  84          string $middlename = null,
  85          string $firstnamephonetic = null,
  86          string $lastnamephonetic = null,
  87          string $alternatename = null,
  88          string $imagealt = null
  89      ) {
  90          $this->id = $id;
  91          $this->pictureitemid = $pictureitemid;
  92          $this->firstname = $firstname;
  93          $this->lastname = $lastname;
  94          $this->fullname = $fullname;
  95          $this->email = $email;
  96          $this->deleted = $deleted;
  97          $this->middlename = $middlename;
  98          $this->firstnamephonetic = $firstnamephonetic;
  99          $this->lastnamephonetic = $lastnamephonetic;
 100          $this->alternatename = $alternatename;
 101          $this->imagealt = $imagealt;
 102      }
 103  
 104      /**
 105       * Return the id.
 106       *
 107       * @return int
 108       */
 109      public function get_id() : int {
 110          return $this->id;
 111      }
 112  
 113      /**
 114       * Return the picture item id.
 115       *
 116       * @return int
 117       */
 118      public function get_picture_item_id() : int {
 119          return $this->pictureitemid;
 120      }
 121  
 122      /**
 123       * Return the first name.
 124       *
 125       * @return string
 126       */
 127      public function get_first_name() : string {
 128          return $this->firstname;
 129      }
 130  
 131      /**
 132       * Return the last name.
 133       *
 134       * @return string
 135       */
 136      public function get_last_name() : string {
 137          return $this->lastname;
 138      }
 139  
 140      /**
 141       * Return the full name.
 142       *
 143       * @return string
 144       */
 145      public function get_full_name() : string {
 146          return $this->fullname;
 147      }
 148  
 149      /**
 150       * Return the email.
 151       *
 152       * @return string
 153       */
 154      public function get_email() : string {
 155          return $this->email;
 156      }
 157  
 158      /**
 159       * Is the author deleted?
 160       *
 161       * @return bool
 162       */
 163      public function is_deleted() : bool {
 164          return !empty($this->deleted);
 165      }
 166  
 167      /**
 168       * Return the middle name.
 169       *
 170       * @return string|null
 171       */
 172      public function get_middle_name() : ?string {
 173          return $this->middlename;
 174      }
 175  
 176      /**
 177       * Return the first name phonetic.
 178       *
 179       * @return string|null
 180       */
 181      public function get_first_name_phonetic() : ?string {
 182          return $this->firstnamephonetic;
 183      }
 184  
 185      /**
 186       * Return the last name phonetic.
 187       *
 188       * @return string|null
 189       */
 190      public function get_last_name_phonetic() : ?string {
 191          return $this->lastnamephonetic;
 192      }
 193  
 194      /**
 195       * Return the alternate name.
 196       *
 197       * @return string|null
 198       */
 199      public function get_alternate_name() : ?string {
 200          return $this->alternatename;
 201      }
 202  
 203      /**
 204       * Return the image alt.
 205       *
 206       * @return string|null
 207       */
 208      public function get_image_alt() : ?string {
 209          return $this->imagealt;
 210      }
 211  }