public function check($userAgent = null)
	 {
		// was a user agent passed? If not, use the server one
		if (empty($userAgent))
		{
			$userAgent = $this->server['http_user_agent'];
		}

		// store the user agent
		$this->userAgent = $userAgent;

		// fetch the data
		switch ($this->method)
		{
			case "browscap":
				// create a browscap object if needed?
				if ( ! $this->browscap)
				{
					if ($this->browscap = new Browscap($this->config['cache_dir']))
					{
						// give the browscap some config
						if ( ! empty($this->config['lowercase']))
						{
							$this->browscap->lowercase = true;
						}

						if (isset($this->config['browscap']))
						{
							foreach ($this->config['browscap'] as $key => $value)
							{
								if (property_exists($this->browscap, $key))
								{
									$this->browscap->{$key} = $value;
								}
							}
						}

						$browscap = $this->browscap->getBrowser($this->userAgent, true);

						$this->properties = array_merge($this->defaults, $browscap);
					}
				}
				break;

			default:
				throw new \InvalidArgumentException('Invalid detection method "'.$this->method.'", can not load browser information.');
		}

		return true;
	}
public function check($userAgent = null)
	 {
		// was a user agent passed? If not, use the server one
		if (empty($userAgent))
		{
			$userAgent = $this->server['http_user_agent'];
		}

		// store the user agent
		$this->userAgent = $userAgent;

		// fetch the data
		switch ($this->method)
		{
			case "browscap":
				// create a browscap object if needed?
				if ( ! $this->browscap)
				{
					if ($this->browscap = new Browscap($this->config['cache_dir']))
					{
						// give the browscap some config
						if ( ! empty($this->config['lowercase']))
						{
							$this->browscap->lowercase = true;
						}

						if (isset($this->config['browscap']))
						{
							foreach ($this->config['browscap'] as $key => $value)
							{
								if (property_exists($this->browscap, $key))
								{
									$this->browscap->{$key} = $value;
								}
							}
						}

						$browscap = $this->browscap->getBrowser($this->userAgent, true);

						$this->properties = array_merge($this->defaults, $browscap);
					}
				}
				break;

			default:
				throw new \InvalidArgumentException('Invalid detection method "'.$this->method.'", can not load browser information.');
		}

		return true;
	}
public function check ( $ userAgent = null ) { // was a user agent passed? If not, use the server one if ( empty ( $ userAgent ) ) { $ userAgent = $ this -> server [ 'http_user_agent' ] ; } // store the user agent $ this -> userAgent = $ userAgent ; // fetch the data switch ( $ this -> method ) { case "browscap" : // create a browscap object if needed? if ( ! $ this -> browscap ) { if ( $ this -> browscap = new Browscap ( $ this -> config [ 'cache_dir' ] ) ) { // give the browscap some config if ( ! empty ( $ this -> config [ 'lowercase' ] ) ) { $ this -> browscap -> lowercase = true ; } if ( isset ( $ this -> config [ 'browscap' ] ) ) { foreach ( $ this -> config [ 'browscap' ] as $ key => $ value ) { if ( property_exists ( $ this -> browscap , $ key ) ) { $ this -> browscap -> { $ key } = $ value ; } } } $ browscap = $ this -> browscap -> getBrowser ( $ this -> userAgent , true ) ; $ this -> properties = array_merge ( $ this -> defaults , $ browscap ) ; } } break ; default : throw new \ InvalidArgumentException ( 'Invalid detection method "' . $ this -> method . '", can not load browser information.' ) ; } return true ; }
Accept a user agent to check, and try to find a match

@param string|null $userAgent User agent string to check

@return boolean True if the check was succesful, false otherwise

@throws \InvalidArgumentException If the method passed to the constuctor is invalid
Accept a user agent to check and try to find a match