Back to Version class

Method getUserAgent

public string
getUserAgent
(string $suffix = '', bool $mask = false, bool $addVersion = true)
Returns the user agent.
Parameters
  • string $suffix String to append to resulting user agent.
  • bool $mask Mask as Mozilla/5.0 or not.
  • bool $addVersion Add version afterwards to component.
Returns
  • string User Agent.
Since
  • 1.0
Class: Version
Project: Joomla

Method getUserAgent - Source code

/**
 * Returns the user agent.
 *
 * @param   string  $suffix      String to append to resulting user agent.
 * @param   bool    $mask        Mask as Mozilla/5.0 or not.
 * @param   bool    $addVersion  Add version afterwards to component.
 *
 * @return  string  User Agent.
 *
 * @since   1.0
 */
public function getUserAgent(string $suffix = '', bool $mask = false, bool $addVersion = true) : string
{
    if ($suffix === '') {
        $suffix = 'Framework';
    }
    if ($addVersion) {
        $suffix .= '/' . self::MAJOR_VERSION . '.' . self::MINOR_VERSION;
    }
    // If masked pretend to look like Mozilla 5.0 but still identify ourselves.
    return ($mask ? 'Mozilla/5.0 ' : '') . self::PRODUCT . '/' . $this->getShortVersion() . ($suffix ? ' ' . $suffix : '');
}