Skip to content

Commit

Permalink
Merge pull request #48 from getyoti/release/1.5.0
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
davidgrayston authored Nov 4, 2020
2 parents dab51a6 + 25aff18 commit f8c6ec2
Show file tree
Hide file tree
Showing 29 changed files with 1,362 additions and 32 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
php: "7.2"
- <<: *compatibility
php: "7.3"
- <<: *compatibility
php: "8.0snapshot"
install:
# Remove php-cs-fixer until compatible with PHP 8
- travis_retry composer remove --dev --no-update --no-interaction friendsofphp/php-cs-fixer
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
before_script:
- echo 'xdebug.mode=coverage' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
script:
- composer test
- <<: *test
stage: Analyze
name: Sonarcloud
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "yoti/yoti-php-sdk-sandbox",
"description": "Yoti PHP SDK Sandbox",
"version": "1.4.0",
"version": "1.5.0",
"keywords": [
"yoti",
"sdk"
],
"homepage": "https://yoti.com",
"license": "MIT",
"require": {
"php": "^7.1 || ^8.0",
"yoti/yoti-php-sdk": "^3.1"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization = getyoti

sonar.projectKey = getyoti:php-sandbox
sonar.projectName = PHP SDK Sandbox
sonar.projectVersion = 1.4.0
sonar.projectVersion = 1.5.0

sonar.language = php
sonar.sources=src
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxSupplementaryDocumentTextDataCheck extends SandboxDocumentCheck
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxSupplementaryDocumentTextDataCheckBuilder extends SandboxDocumentCheckBuilder
{
/**
* @var array<string, mixed>|null
*/
private $documentFields;

/**
* @param string $key
* @param mixed $value
*/
public function withDocumentField(string $key, $value): self
{
$this->documentFields[$key] = $value;
return $this;
}

/**
* @param array<string, mixed> $documentFields
* @return $this
*/
public function withDocumentFields(array $documentFields): self
{
$this->documentFields = $documentFields;
return $this;
}

/**
* @return SandboxSupplementaryDocumentTextDataCheck
*/
public function build(): SandboxCheck
{
$result = new SandboxSupplementaryDocumentTextDataCheckResult($this->buildReport(), $this->documentFields);
return new SandboxSupplementaryDocumentTextDataCheck($result, $this->documentFilter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace Yoti\Sandbox\DocScan\Request\Check;

use Yoti\Sandbox\DocScan\Request\Check\Report\SandboxCheckReport;

class SandboxSupplementaryDocumentTextDataCheckResult extends SandboxCheckResult
{

/**
* @var array<string, mixed>|null
*/
private $documentFields;

/**
* @param SandboxCheckReport $report
* @param array<string, mixed>|null $documentFields
*/
public function __construct(
SandboxCheckReport $report,
?array $documentFields
) {
parent::__construct($report);
$this->documentFields = $documentFields;
}

/**
* @return \stdClass
*/
public function jsonSerialize(): \stdClass
{
$jsonData = parent::jsonSerialize();

if ($this->documentFields !== null) {
$jsonData->document_fields = (object) $this->documentFields;
}

return $jsonData;
}
}
13 changes: 11 additions & 2 deletions src/DocScan/Request/SandboxCheckReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentTextDataCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxIdDocumentComparisonCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxLivenessCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxSupplementaryDocumentTextDataCheck;
use Yoti\Util\Json;

class SandboxCheckReports implements \JsonSerializable
{

/**
* @var SandboxDocumentTextDataCheck[]
*/
Expand All @@ -34,6 +34,11 @@ class SandboxCheckReports implements \JsonSerializable
*/
private $documentFaceMatchChecks;

/**
* @var SandboxSupplementaryDocumentTextDataCheck[]|null
*/
private $supplementaryDocumentTextDataChecks;

/**
* @var SandboxLivenessCheck[]
*/
Expand All @@ -53,21 +58,24 @@ class SandboxCheckReports implements \JsonSerializable
* @param SandboxLivenessCheck[] $livenessChecks
* @param int|null $asyncReportDelay
* @param SandboxIdDocumentComparisonCheck[]|null $idDocumentComparisonChecks
* @param SandboxSupplementaryDocumentTextDataCheck[]|null $supplementaryDocumentTextDataChecks
*/
public function __construct(
array $documentTextDataChecks,
array $documentAuthenticityChecks,
array $documentFaceMatchChecks,
array $livenessChecks,
?int $asyncReportDelay,
?array $idDocumentComparisonChecks = null
?array $idDocumentComparisonChecks = null,
?array $supplementaryDocumentTextDataChecks = null
) {
$this->documentTextDataChecks = $documentTextDataChecks;
$this->documentAuthenticityChecks = $documentAuthenticityChecks;
$this->documentFaceMatchChecks = $documentFaceMatchChecks;
$this->livenessChecks = $livenessChecks;
$this->asyncReportDelay = $asyncReportDelay;
$this->idDocumentComparisonChecks = $idDocumentComparisonChecks;
$this->supplementaryDocumentTextDataChecks = $supplementaryDocumentTextDataChecks;
}

/**
Expand All @@ -80,6 +88,7 @@ public function jsonSerialize(): \stdClass
'ID_DOCUMENT_AUTHENTICITY' => $this->documentAuthenticityChecks,
'ID_DOCUMENT_FACE_MATCH' => $this->documentFaceMatchChecks,
'ID_DOCUMENT_COMPARISON' => $this->idDocumentComparisonChecks,
'SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK' => $this->supplementaryDocumentTextDataChecks,
'LIVENESS' => $this->livenessChecks,
'async_report_delay' => $this->asyncReportDelay,
]);
Expand Down
21 changes: 19 additions & 2 deletions src/DocScan/Request/SandboxCheckReportsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentTextDataCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxIdDocumentComparisonCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxLivenessCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxSupplementaryDocumentTextDataCheck;

class SandboxCheckReportsBuilder
{

/**
* @var SandboxDocumentTextDataCheck[]
*/
Expand All @@ -38,6 +38,11 @@ class SandboxCheckReportsBuilder
*/
private $livenessChecks = [];

/**
* @var SandboxSupplementaryDocumentTextDataCheck[]
*/
private $supplementaryDocumentTextDataChecks = [];

/**
* @var int
*/
Expand Down Expand Up @@ -103,6 +108,17 @@ public function withAsyncReportDelay(int $asyncReportDelay): self
return $this;
}

/**
* @param SandboxSupplementaryDocumentTextDataCheck $supplementaryDocumentTextDataCheck
* @return $this
*/
public function withSupplementaryDocumentTextDataCheck(
SandboxSupplementaryDocumentTextDataCheck $supplementaryDocumentTextDataCheck
): self {
$this->supplementaryDocumentTextDataChecks[] = $supplementaryDocumentTextDataCheck;
return $this;
}

/**
* @return SandboxCheckReports
*/
Expand All @@ -114,7 +130,8 @@ public function build(): SandboxCheckReports
$this->documentFaceMatchChecks,
$this->livenessChecks,
$this->asyncReportDelay,
$this->idDocumentComparisonChecks
$this->idDocumentComparisonChecks,
$this->supplementaryDocumentTextDataChecks
);
}
}
23 changes: 17 additions & 6 deletions src/DocScan/Request/SandboxTaskResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

namespace Yoti\Sandbox\DocScan\Request;

use Yoti\DocScan\Constants;
use Yoti\Sandbox\DocScan\Request\Task\SandboxDocumentTextDataExtractionTask;
use Yoti\Sandbox\DocScan\Request\Task\SandboxSupplementaryDocumentTextDataExtractionTask;
use Yoti\Util\Json;

class SandboxTaskResults implements \JsonSerializable
{
Expand All @@ -14,21 +15,31 @@ class SandboxTaskResults implements \JsonSerializable
*/
private $documentTextDataExtractionTasks;

/**
* @var SandboxSupplementaryDocumentTextDataExtractionTask[]|null
*/
private $supplementaryDocumentTextDataExtractionTasks;

/**
* @param SandboxDocumentTextDataExtractionTask[] $documentTextDataExtractionTasks
* @param SandboxSupplementaryDocumentTextDataExtractionTask[] $supplementaryDocumentTextDataExtractionTasks
*/
public function __construct(array $documentTextDataExtractionTasks)
{
public function __construct(
array $documentTextDataExtractionTasks,
?array $supplementaryDocumentTextDataExtractionTasks
) {
$this->documentTextDataExtractionTasks = $documentTextDataExtractionTasks;
$this->supplementaryDocumentTextDataExtractionTasks = $supplementaryDocumentTextDataExtractionTasks;
}

/**
* @return \stdClass
*/
public function jsonSerialize(): \stdClass
{
return (object) [
Constants::ID_DOCUMENT_TEXT_DATA_EXTRACTION => $this->documentTextDataExtractionTasks,
];
return (object) Json::withoutNullValues([
'ID_DOCUMENT_TEXT_DATA_EXTRACTION' => $this->documentTextDataExtractionTasks,
'SUPPLEMENTARY_DOCUMENT_TEXT_DATA_EXTRACTION' => $this->supplementaryDocumentTextDataExtractionTasks,
]);
}
}
23 changes: 22 additions & 1 deletion src/DocScan/Request/SandboxTaskResultsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Yoti\Sandbox\DocScan\Request;

use Yoti\Sandbox\DocScan\Request\Task\SandboxDocumentTextDataExtractionTask;
use Yoti\Sandbox\DocScan\Request\Task\SandboxSupplementaryDocumentTextDataExtractionTask;

class SandboxTaskResultsBuilder
{
Expand All @@ -13,6 +14,11 @@ class SandboxTaskResultsBuilder
*/
private $documentTextDataExtractionTasks = [];

/**
* @var SandboxSupplementaryDocumentTextDataExtractionTask[]
*/
private $supplementaryDocumentTextDataExtractionTasks = [];

/**
* @param SandboxDocumentTextDataExtractionTask $documentTextDataExtractionTask
*
Expand All @@ -25,11 +31,26 @@ public function withDocumentTextDataExtractionTask(
return $this;
}

/**
* @param SandboxSupplementaryDocumentTextDataExtractionTask $supplementaryDocumentTextDataExtractionTask
*
* @return $this
*/
public function withSupplementaryDocumentTextDataExtractionTask(
SandboxSupplementaryDocumentTextDataExtractionTask $supplementaryDocumentTextDataExtractionTask
): self {
$this->supplementaryDocumentTextDataExtractionTasks[] = $supplementaryDocumentTextDataExtractionTask;
return $this;
}

/**
* @return SandboxTaskResults
*/
public function build()
{
return new SandboxTaskResults($this->documentTextDataExtractionTasks);
return new SandboxTaskResults(
$this->documentTextDataExtractionTasks,
$this->supplementaryDocumentTextDataExtractionTasks
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class SandboxDocumentTextDataExtractionTask implements \JsonSerializable
{

/**
* @var SandboxDocumentTextDataExtractionTaskResult
*/
Expand Down
Loading

0 comments on commit f8c6ec2

Please sign in to comment.