Skip to content

Commit

Permalink
Added some links to relevant RFC-specifications
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPetterMG committed Jul 15, 2016
1 parent 91eb911 commit bce63bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Class UserAgentParser
*
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
* @link https://tools.ietf.org/html/rfc7231
* @link https://tools.ietf.org/html/rfc7230
*
* @package vipnytt
Expand Down Expand Up @@ -38,7 +38,7 @@ class UserAgentParser
private $version;

/**
* Constructor
* UserAgentParser constructor
*
* @param string $product
* @param int|string|null $version
Expand Down Expand Up @@ -70,6 +70,7 @@ private function split()

/**
* Validate the Product format
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
* @link https://tools.ietf.org/html/rfc7230#section-3.2.4
*
* @return bool
Expand All @@ -92,6 +93,7 @@ private function validateProduct()
* Check for blacklisted strings or characters
*
* @param int|string|null $input
* @return bool
* @throws FormatException
*/
private function blacklistCheck($input)
Expand All @@ -107,10 +109,12 @@ private function blacklistCheck($input)
throw new FormatException('Invalid User-agent format (`' . trim($this->product . '/' . $this->version, '/') . '`). Examples of valid User-agents: `MyCustomBot`, `MyFetcher-news`, `MyCrawler/2.1` and `MyBot-images/1.2`. See also ' . self::RFC_README);
}
}
return true;
}

/**
* Validate the Version and it's format
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
*
* @return bool
* @throws VersionException
Expand All @@ -125,7 +129,7 @@ private function validateVersion()
version_compare($this->version, '0.0.1', '>=') === false
)
) {
throw new VersionException('Invalid version format (`' . $this->version . '`). See http://semver.org/ for guidelines. In addition, dev/alpha/beta/rc tags is disallowed. See also ' . self::RFC_README);
throw new VersionException("Invalid version format (` $this->version `). See http://semver.org/ for guidelines. In addition, dev/alpha/beta/rc tags is disallowed. See also " . self::RFC_README);
}
$this->version = trim($this->version, '.0');
return true;
Expand Down

0 comments on commit bce63bb

Please sign in to comment.