[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Event/Plugin/System/Webauthn/ -> AjaxChallenge.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  namespace Joomla\CMS\Event\Plugin\System\Webauthn;
  11  
  12  use InvalidArgumentException;
  13  use Joomla\CMS\Event\AbstractImmutableEvent;
  14  use Joomla\CMS\Event\Result\ResultAware;
  15  use Joomla\CMS\Event\Result\ResultAwareInterface;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Concrete event class for the onAjaxWebauthnChallenge event
  23   *
  24   * @since  4.2.0
  25   */
  26  class AjaxChallenge extends AbstractImmutableEvent implements ResultAwareInterface
  27  {
  28      use ResultAware;
  29  
  30      /**
  31       * Make sure the result is valid JSON or boolean false
  32       *
  33       * @param   mixed  $data  The data to check
  34       *
  35       * @return  void
  36       * @since   4.2.0
  37       */
  38      public function typeCheckResult($data): void
  39      {
  40          if ($data === false) {
  41              return;
  42          }
  43  
  44          if (!is_string($data) || @json_decode($data) === null) {
  45              throw new InvalidArgumentException(sprintf('Event %s only accepts JSON results.', $this->getName()));
  46          }
  47      }
  48  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer