Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.

Commit 0577590

Browse files
committed
Added global matched percent to request based on the results highest percent
1 parent 5e17d39 commit 0577590

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: php
2+
php:
3+
- 5.6
4+
5+
before_script:
6+
- composer self-update
7+
- composer install
8+
9+
script: phpunit
10+
11+
notifications:
12+
email: false
13+
14+
branches:
15+
only:
16+
- master

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "~5.0",
21-
"phpunit/phpunit-mock-objects": "~3.0",
2221
"illuminate/support": "^5.3"
2322
},
2423
"autoload": {

src/Models/Report.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@
66
* @property int words Words of request
77
* @property float cost Credits of request
88
* @property array results Results of report
9+
* @property int percentage Percent matched of request
910
* @author Marcos Per <marcosperg@gmail.com>
1011
* @copyright Copyright (c) 2019
1112
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1213
*/
1314
class Report{
1415

15-
function __construct($xml)
16+
function __construct($xml,$c = 0)
1617
{
1718
$this->results = array();
1819
$this->viewUrl = (string) $xml->allviewurl;
1920
$this->words = (int) $xml->querywords;
2021
$this->cost = (float) $xml->cost;
22+
$this->percentage = 0;
2123

2224
if($xml->count > 0){
23-
foreach ($xml->result as $result){
24-
array_push($this->results,new Result($result));
25+
foreach ($xml->result as $xmlResult){
26+
$result = new Result($xmlResult);
27+
28+
//Find the highest matchpercent
29+
if($result->getPercentMatched() !== null && $result->getPercentMatched() > $this->percentage) $this->percentage = $result->getPercentMatched();
30+
31+
array_push($this->results,$result);
2532
}
2633
}
2734
}
@@ -33,6 +40,13 @@ public function isOriginal(){
3340
return count($this->results) == 0;
3441
}
3542

43+
/*
44+
* Get the highest match percent
45+
*/
46+
public function getMatchedPercent(){
47+
return $this->percentage;
48+
}
49+
3650
/*
3751
* Get url of report
3852
*/

0 commit comments

Comments
 (0)