PHP code example of arnaudleroy-studio / coffeetrove

1. Go to this page and download the library: Download arnaudleroy-studio/coffeetrove library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arnaudleroy-studio / coffeetrove example snippets


use CoffeeTrove\Client;

$client = new Client();

// Find cafes near a coordinate pair
$cafes = $client->searchCafes(
    latitude: 48.8566,
    longitude: 2.3522,
    radiusKm: 2,
    limit: 10,
);

foreach ($cafes as $cafe) {
    echo "{$cafe['name']} — score: {$cafe['score']}/100\n";
}

// Golden Drop tier thresholds
$tiers = Client::SCORE_TIERS;
// ['exceptional' => 90, 'excellent' => 80, 'notable' => 70, 'common' => 0]

$cafe = $client->getCafe(slug: 'blue-bottle-shinjuku');
$tier = $client->getTier(score: $cafe?->score ?? 0);

echo "{$cafe?->name}: {$tier} tier";

// Retrieve all brewing method profiles
$methods = $client->getBrewingMethods();

// Array destructuring for clean iteration
foreach ($methods as ['slug' => $slug, 'name' => $name, 'grind' => $grind]) {
    echo "{$name} 

$origins = $client->getOrigins(region: 'africa');

// Null-safe chaining on optional tasting notes
foreach ($origins as $origin) {
    $notes = $origin?->getData('tasting_notes') ?? 'no tasting notes available';
    echo "{$origin['name']}: {$notes}\n";
}