PHPackages                             ufo-tech/petrol-prices - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. ufo-tech/petrol-prices

ActiveLibrary[Caching](/categories/caching)

ufo-tech/petrol-prices
======================

Library to fetch and cache petrol prices from public resources.

1.0.0(1y ago)053MITPHPPHP ^8.3

Since Dec 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/UFO-Tech/petrol-prices)[ Packagist](https://packagist.org/packages/ufo-tech/petrol-prices)[ RSS](/packages/ufo-tech-petrol-prices/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Fuel Price Service
==================

[](#fuel-price-service)

Description
-----------

[](#description)

`Fuel Price Service` is a PHP library for fetching and caching up-to-date fuel prices from various providers.
It supports PSR-compliant interfaces for better integration into modern PHP projects.

Features
--------

[](#features)

- Fetch fuel prices from providers via API.
- Automatic caching with customizable TTL.
- Easy addition of new data providers through interfaces.
- Exception handling for errors during data retrieval.

Installation
------------

[](#installation)

Install the library via Composer:

```
composer require ufo/petrol-prices
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Ufo\PetrolPrices\FuelPriceService;
use Ufo\PetrolPrices\Providers\AutoRiaFuelPriceProvider;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\HttpClient\HttpClient;

$httpClient = HttpClient::create();
$cache = new FilesystemAdapter();
$provider = new AutoRiaFuelPriceProvider($httpClient);

$service = new FuelPriceService($provider, $cache);

try {
    $fuelPrices = $service->getFuelPrices();
    echo "Date: {$fuelPrices->date}\n";
    echo "A-95 Premium: {$fuelPrices->a95Plus} UAH\n";
    echo "A-95: {$fuelPrices->a95} UAH\n";
    echo "A-92: {$fuelPrices->a92} UAH\n";
    echo "Diesel: {$fuelPrices->diesel} UAH\n";
    echo "Gas: {$fuelPrices->gas} UAH\n";
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

### Usage Without Caching

[](#usage-without-caching)

```
$service = new FuelPriceService($provider);
$fuelPrices = $service->getFuelPrices();
```

### Usage with Custom TTL

[](#usage-with-custom-ttl)

```
$service = new FuelPriceService($provider, $cache, cacheTtl: 7200); // Cache for 2 hours
$fuelPrices = $service->getFuelPrices();
```

Extending
---------

[](#extending)

To add a new provider, implement the `IFuelPriceProvider` interface:

```
namespace Ufo\PetrolPrices\Interfaces;

use Ufo\PetrolPrices\DTO\FuelPrice;

interface IFuelPriceProvider
{
    public function getFuelPrices(): FuelPrice;
}
```

Testing
-------

[](#testing)

Run tests using PHPUnit:

```
vendor/bin/phpunit tests/
```

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance40

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87aea0bcf81c64ced7c3a14a1746d603ec6e8acfba62ef85746df40e8c376e7f?d=identicon)[Alex Maistrenko](/maintainers/Alex%20Maistrenko)

---

Top Contributors

[![Ashterix](https://avatars.githubusercontent.com/u/5172394?v=4)](https://github.com/Ashterix "Ashterix (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ufo-tech-petrol-prices/health.svg)

```
[![Health](https://phpackages.com/badges/ufo-tech-petrol-prices/health.svg)](https://phpackages.com/packages/ufo-tech-petrol-prices)
```

###  Alternatives

[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)[incenteev/hashed-asset-bundle

Apply an asset version based on a hash of the asset for symfony/asset

25526.7k1](/packages/incenteev-hashed-asset-bundle)[rikudou/psr6-dynamo-db-bundle

PSR-6 and PSR-16 cache implementation using AWS DynamoDB for Symfony

2077.8k](/packages/rikudou-psr6-dynamo-db-bundle)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1322.1k12](/packages/mahocommerce-maho)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
