PHPackages                             anteris-dev/faker-map - 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. anteris-dev/faker-map

ActiveLibrary

anteris-dev/faker-map
=====================

Guesses which Faker provider method you might need based on the name passed.

v2.0.0(5y ago)0236.0k—0%2MITPHPPHP ^8.0

Since Dec 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Anteris-Dev/faker-map)[ Packagist](https://packagist.org/packages/anteris-dev/faker-map)[ RSS](/packages/anteris-dev-faker-map/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (2)

Your Factory's Guide to Faking
==============================

[](#your-factorys-guide-to-faking)

[![Tests](https://github.com/Anteris-Dev/faker-map/workflows/Tests/badge.svg)](https://github.com/Anteris-Dev/faker-map/actions?query=workflow%3ATests)[![Style](https://github.com/Anteris-Dev/faker-map/workflows/Style/badge.svg)](https://github.com/Anteris-Dev/faker-map/actions?query=workflow%3AStyle)

Have you ever wanted faker to just create some values for you automatically without having to instruct it on what they represent? Yeah, probably not, but at least you now know it's possible!

This package allows you to dynamically lookup the method you might be looking for by doing something like this: `FakerMap::new()->closest('male name')->fake()`.

So how do you install it? How does it work? Let's dive in!

To Install
----------

[](#to-install)

Run `composer require anteris-dev/faker-map`.

Getting Started
---------------

[](#getting-started)

```
use Anteris\FakerMap\FakerMap;
use Faker\Factory;

// FakerMap will handle creating a faker instance for you here.
$map = FakerMap::new();

// Or you can pass in your own instance. This is handy for seeding!
$faker = Factory::create();
$faker->seed(123);

$map = new FakerMap($faker);
```

This `FakerMap` class comes with three useful methods for dynamically figuring out what value should be generated. The first of these methods is `closeEnough()`. This method takes a single string and finds the first possible Faker method that even comes close to matching it.

The second method is `closest()`. This also takes a single string but it tries to find the closest possible match to the Faker value you are looking for.

Finally, the `guess()` method allows you to determine how close or distant the match is. Its first parameter is the query and the second is an integer that defines how many letters may be changed in your query to make the match.

Each of these methods returns an instance of `Anteris\FakerMap\FakerMap` which gives you various addon methods that can be called to help you with your search for the perfect method. These methods are:

- `default($value)` - Lets you define a default value in case we cannot find an appropriate method on the Faker class.
- `type(string $type)` - Lets you define the type the returned value should have. If the faked value doesn't match the type, null or default will be returned instead.
- `fake(...$parameters)` - Takes all the information gathered and returns the end result. Any parameters passed will be used in the faker method.
- `faker()` - Returns the underlying instance of faker for any use you may have for it.

See examples of all of these below:

```
FakerMap::new()->closeEnough('female name')->fake();

FakerMap::new()->closest('female name')->fake();

FakerMap::new()->guess('female name', 3)->fake();

// A guess that passes some parameters
// Returns: A number between 1 and 40
FakerMap::new()->closest('number between')->fake(1, 40);

// A guess that definitely won't have a match so it defaults to "Yikes!"
FakerMap::new()->closest('some unknown value')->default('Yikes!')->fake();

// Passes on to the underlying faker instance.
FakerMap::new()->faker()->firstNameFemale();
```

But why?
========

[](#but-why)

Why did we choose to create this package? Well, we wanted to be able to fake realistic values based on the names of properties retrieved using PHPs reflection API. This would allow us to fill the following class with realistic data. Pretty cool right?

```
class Person {
	public string $firstName;
	public string $lastName;
	public string $companyName;
	public string $email;
	public string $address1;
	public string $address2;
	public string $socialSecurityNumber;
}
```

Reference
=========

[](#reference)

There are some cool packages out there that do some cool things with Faker. While it did not suit our needs, Jason McCreary put together a nice Faker Registry package that does some similar things for generating Laravel Factory files. It may be worth checking out [here](https://github.com/laravel-shift/faker-registry). His registry array inspired our `FakerDictionary` class.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~33 days

Total

5

Last Release

1850d ago

Major Versions

v0.1.0 → v1.0.02020-12-12

v1.1.0 → v2.0.02021-04-16

PHP version history (2 changes)v1.0.1PHP ^7.4|^8.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dca3c3ac71024f7878526a0fe0a384fbf198ed711fe7e7bb34177a1dbc849f6?d=identicon)[golthem](/maintainers/golthem)

---

Top Contributors

[![aidan-casey](https://avatars.githubusercontent.com/u/6686277?v=4)](https://github.com/aidan-casey "aidan-casey (4 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/anteris-dev-faker-map/health.svg)

```
[![Health](https://phpackages.com/badges/anteris-dev-faker-map/health.svg)](https://phpackages.com/packages/anteris-dev-faker-map)
```

###  Alternatives

[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8017.0M43](/packages/orchestra-workbench)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[webfactory/slimdump

slimdump is a little tool to help you creating dumps of large MySQL-databases.

188124.8k1](/packages/webfactory-slimdump)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)

PHPackages © 2026

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