Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\Functions;
   6  use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
   7  use PhpOffice\PhpSpreadsheet\Cell\Cell;
   8  
   9  class Hyperlink
  10  {
  11      /**
  12       * HYPERLINK.
  13       *
  14       * Excel Function:
  15       *        =HYPERLINK(linkURL, [displayName])
  16       *
  17       * @param mixed $linkURL Expect string. Value to check, is also the value returned when no error
  18       * @param mixed $displayName Expect string. Value to return when testValue is an error condition
  19       * @param Cell $cell The cell to set the hyperlink in
  20       *
  21       * @return mixed The value of $displayName (or $linkURL if $displayName was blank)
  22       */
  23      public static function set($linkURL = '', $displayName = null, ?Cell $cell = null)
  24      {
  25          $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
  26          $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
  27  
  28          if ((!is_object($cell)) || (trim($linkURL) == '')) {
  29              return ExcelError::REF();
  30          }
  31  
  32          if ((is_object($displayName)) || trim($displayName) == '') {
  33              $displayName = $linkURL;
  34          }
  35  
  36          $cell->getHyperlink()->setUrl($linkURL);
  37          $cell->getHyperlink()->setTooltip($displayName);
  38  
  39          return $displayName;
  40      }
  41  }