File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Changelog
2+
3+ All notable changes to this project will be documented in this file.
4+
5+ The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.1.0/ ) ,
6+ and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7+
8+
9+ ## v3.0.0
10+
11+ ### Added
12+ - ` detectBatch ` method for batch detections
13+
14+ ### Changed
15+ - Switched to v3 API which uses updated language detection model
16+ - ⚠️ ` simpleDetect ` method renamed to ` detectCode `
17+ - ⚠️ ` detect ` method result fields are ` language ` and ` score `
18+ - ⚠️ ` detect ` method no longer accept arrays - use ` detectBatch ` instead
19+ - HTTPS is used by default. Removed secure mode configuration.
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ Create or add the following to composer.json in your project root:
2828}
2929```
3030
31+ ## Upgrading
32+
33+ When upgrading please check [ changelog] ( CHANGELOG.md ) for breaking changes.
34+
3135## Usage
3236
3337### Configuration
Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ public static function setApiKey($apiKey)
5858 */
5959 public static function detect ($ text )
6060 {
61+ if (is_array ($ text )) {
62+ throw new Error ('detect method does not accept arrays, use detectBatch instead ' );
63+ }
64+
6165 return Client::request ('POST ' , 'detect ' , array ('q ' => $ text ));
6266 }
6367
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function testConstructor()
2323 'Expect the API key to be set. ' );
2424 }
2525
26- public function testDetection ()
26+ public function testDetect ()
2727 {
2828 $ result = DetectLanguage::detect ('Hello world ' );
2929
@@ -36,6 +36,12 @@ public function testDetection()
3636 'To detect Lithuanian language. ' );
3737 }
3838
39+ public function testDetectWithArray ()
40+ {
41+ $ this ->expectException ('\DetectLanguage\Error ' );
42+ $ result = DetectLanguage::detect (array ('Hello world ' ));
43+ }
44+
3945 public function testDetectCode ()
4046 {
4147 $ result = DetectLanguage::detectCode ('Hello world ' );
You can’t perform that action at this time.
0 commit comments