1. Go to this page and download the library: Download byscripts/static-entity 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/ */
// Get an instance of WebBrowser, hydrated with Firefox data
$firefox = WebBrowser::get(WebBrowser::FIREFOX);
// Instanciated objects are singleton
WebBrowser::get(WebBrowser::FIREFOX) === WebBrowser::get(WebBrowser::FIREFOX); // true
// The getId() method is always available.
// It returns the key used in the getDataSet() method;
$firefox->getId(); // 2
// Other methods are ones implemented in the static entity
$firefox->getName(); // Firefox
// The toId() method transform an entity to ID.
// If an id is passed, it is returned as is, after checking it exists.
// The method is mainly intended for a setter method to accept both type.
WebBrowser::toId($firefox); // 2
WebBrowser::toId(2); // 2
// The getIds() method returns an array of all ids present in data set
WebBrowser::getIds(); // [1, 2, 3, 4, 5]
// The getAssoc() returns an associative array with `id` as key and `name` as value
WebBrowser::getAssociative(); // [1 => 'Chromium', 2 => 'Firefox', ...]
// You can also pass the name of an argument you want to use as value
WebBrowser::getAssociative('brand'); // [1 => 'Google', 2 => 'Mozilla', 3 => 'Microsoft', ...]
// The getAll() method returns an array containing all instances of entities
WebBrowser::getAll(); // [Object, Object, ...]
// The exists() method check whether the passed ID exists in data set
WebBrowser::hasId(3); // true
WebBrowser::hasId(9); // false