nawarian / The-PHP-Website

Yet another php website
https://thephp.website
33 stars 12 forks source link

/archive-org-client -- Archive.org metadata 'collection' is now an array #56

Open tim-andes opened 3 years ago

tim-andes commented 3 years ago

Error:

1) Nawarian\ArchiveOrg\Test\ClientTest::testClientFetchesMetadata
TypeError: Argument 3 passed to Nawarian\ArchiveOrg\Item\Metadata::__construct() must be of the type string, array given, called in /Coding/archive-org-client/src/Client.php on line 18

Info from archive.org

  "metadata": {
    "backup_location": "ia905607_28",
    "collection": [
      "bell_literature",
      "bell",
      "additional_collections"
    ],

The [likely rudimentary] fix I've found is that within Client.php, make sure that the new instance of Metadata returns the first item in the collection array:

        return new Metadata(
            $metadata['identifier'],
            $metadata['publicdate'],
            $metadata['collection'][0]
tim-andes commented 3 years ago

Happy to create a PR if this is the appropriate fix. If not, feel free to share the appropriate fix!