PHPackages                             tiny-blocks/country - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. tiny-blocks/country

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

tiny-blocks/country
===================

Provides an ISO 3166-1 country value object for PHP, with Alpha-2, Alpha-3, numeric, and IANA timezone resolution.

4.0.0(1mo ago)322.4k↓90.9%MITPHPPHP ^8.5CI passing

Since Jul 26Pushed 1mo agoCompare

[ Source](https://github.com/tiny-blocks/country)[ Packagist](https://packagist.org/packages/tiny-blocks/country)[ Docs](https://github.com/tiny-blocks/country)[ RSS](/packages/tiny-blocks-country/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (13)Versions (17)Used By (0)

Country
=======

[](#country)

[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://github.com/tiny-blocks/country/blob/main/LICENSE)

- [Overview](#overview)
- [Installation](#installation)
- [How to use](#how-to-use)
    - [Alpha2Code](#alpha2code)
    - [Alpha3Code](#alpha3code)
    - [NumericCode](#numericcode)
    - [Country](#country-1)
        - [Creating from objects](#creating-from-objects)
        - [Creating from string](#creating-from-string)
        - [Creating from string with safe fallback](#creating-from-string-with-safe-fallback)
    - [Timezones](#timezones)
        - [Getting all timezones](#getting-all-timezones)
        - [Getting the default timezone](#getting-the-default-timezone)
        - [Finding a timezone by identifier with UTC fallback](#finding-a-timezone-by-identifier-with-utc-fallback)
        - [Checking if a timezone belongs to the country](#checking-if-a-timezone-belongs-to-the-country)
- [License](#license)
- [Contributing](#contributing)

Overview
--------

[](#overview)

Provides an [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) country value object for PHP, carrying Alpha-2, Alpha-3, and numeric codes along with all [IANA timezones](https://www.iana.org) associated with the country. Supports construction from any of the three code variants and automatic conversion between them. Built on top of the tiny-blocks value-object contract to guarantee immutability and structural equality.

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

[](#installation)

```
composer require tiny-blocks/country
```

How to use
----------

[](#how-to-use)

The library exposes country codes according to ISO 3166-1 specifications. It is possible to create a representation of a country that groups the codes, its name, and all its IANA timezones.

### Alpha2Code

[](#alpha2code)

A two-letter code that represents a country name, recommended as the general purpose code.

```
