delboy1978uk/country

A PHP library of countries and flags.

v2.4.3 2024-03-31 13:15 UTC

This package is auto-updated.

Last update: 2024-03-31 13:17:26 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License
build status Code Coverage Scrutinizer Code Quality
A countries and flags library in PHP.

installation

Install via composer into your project:

composer require delboy1978uk/country

usage

factory

You can call CountryFactory::generate($code) to create a country object

public static function generate(string $id): Country;

entity

public function __toString();
public function getFlag(): string;
public function getId(): string;
public function getIso(): string;
public function getName(): string;
public function getNumCode(): int;
public function setFlag(string $flag): void;
public function setId(string $id): void
public function setIso(string $iso): void;
public function setName(string $name): void;
public function setNumCode(int $numCode): void;
public function toArray(): array;

trait

You can use HasCountryTrait to add a country to your object (also works with doctrine)

public function getCountry(): Country;
public function setCountry(Country $country): void;

flag image helper

You can call Flag::render($country, $size), where size can be one of tiny, small, medium, or large.

 public static function render(Country $country, $size)