Skip to content

Commit bce63bb

Browse files
committed
Added some links to relevant RFC-specifications
1 parent 91eb911 commit bce63bb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/UserAgentParser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class UserAgentParser
1010
*
11-
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
11+
* @link https://tools.ietf.org/html/rfc7231
1212
* @link https://tools.ietf.org/html/rfc7230
1313
*
1414
* @package vipnytt
@@ -38,7 +38,7 @@ class UserAgentParser
3838
private $version;
3939

4040
/**
41-
* Constructor
41+
* UserAgentParser constructor
4242
*
4343
* @param string $product
4444
* @param int|string|null $version
@@ -70,6 +70,7 @@ private function split()
7070

7171
/**
7272
* Validate the Product format
73+
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
7374
* @link https://tools.ietf.org/html/rfc7230#section-3.2.4
7475
*
7576
* @return bool
@@ -92,6 +93,7 @@ private function validateProduct()
9293
* Check for blacklisted strings or characters
9394
*
9495
* @param int|string|null $input
96+
* @return bool
9597
* @throws FormatException
9698
*/
9799
private function blacklistCheck($input)
@@ -107,10 +109,12 @@ private function blacklistCheck($input)
107109
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);
108110
}
109111
}
112+
return true;
110113
}
111114

112115
/**
113116
* Validate the Version and it's format
117+
* @link https://tools.ietf.org/html/rfc7231#section-5.5.3
114118
*
115119
* @return bool
116120
* @throws VersionException
@@ -125,7 +129,7 @@ private function validateVersion()
125129
version_compare($this->version, '0.0.1', '>=') === false
126130
)
127131
) {
128-
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);
132+
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);
129133
}
130134
$this->version = trim($this->version, '.0');
131135
return true;

0 commit comments

Comments
 (0)