Skip to content

Commit

Permalink
Remove import of license information
Browse files Browse the repository at this point in the history
  • Loading branch information
mzur committed Sep 30, 2024
1 parent 53caf84 commit 3ae9d6b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 644 deletions.
29 changes: 0 additions & 29 deletions src/Coco.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Coco
public Info $info;
public array $images;
public array $annotations;
public ?array $licenses;
public array $categories;

public static function getCocoUser(): User
Expand Down Expand Up @@ -56,15 +55,7 @@ public static function create(array $data): self
return Category::create($categoryData);
}, $data['categories']);

// Create the License objects
if (array_key_exists('licenses', $data)) {
$instance->licenses = array_map(function ($licenseData) {
return License::create($licenseData);
}, $data['licenses']);
}

// validate the data consistency
$instance->validateLicensesInData();
$instance->validateCategoriesInData();
$instance->validateImagesInData();

Expand All @@ -82,26 +73,6 @@ public static function validate(array $data): void
}
}

/**
* Validate that all image license IDs are valid.
*/
public function validateLicensesInData(): void
{
if (!isset($this->licenses)) {
return;
}

$licenseIds = array_map(function ($license) {
return $license->id;
}, $this->licenses);

foreach ($this->images as $image) {
if (isset($image->license) && !in_array($image->license, $licenseIds)) {
throw new \Exception("Invalid license ID '{$image->license}' in image '{$image->id}'");
}
}
}

public function validateCategoriesInData(): void
{
$categoryIds = array_map(function ($category) {
Expand Down
33 changes: 0 additions & 33 deletions src/License.php

This file was deleted.

14 changes: 0 additions & 14 deletions tests/CocoParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ public function testRecognizesCorrectFileWithAdditionalData()
$this->assertTrue($parser->recognizesFile());
}

public function testRecognizesCorrectFileWithLicense()
{
$file = new File(__DIR__ . "/files/license-coco-import-volume.json");
$parser = new CocoParser($file);
$this->assertTrue($parser->recognizesFile());
}

public function testRecognizesMissingCategoryFile()
{
$file = new File(__DIR__ . "/files/missing-category-coco-import-volume.json");
Expand All @@ -48,13 +41,6 @@ public function testRecognizesEmptyFile()
$this->assertFalse($parser->recognizesFile());
}

public function testRecognizesBrokenLicenseFile()
{
$file = new File(__DIR__ . "/files/broken-license-coco-import-volume.json");
$parser = new CocoParser($file);
$this->assertFalse($parser->recognizesFile());
}

public function testGetMetadata()
{
$file = new File(__DIR__ . "/files/full-coco-import-volume.json");
Expand Down
284 changes: 0 additions & 284 deletions tests/files/broken-license-coco-import-volume.json

This file was deleted.

Loading

0 comments on commit 3ae9d6b

Please sign in to comment.