<commit_before># sensible
A PHP library for finding sensible user programs, like editor, pager, and browser.

[![Build Status](http://img.shields.io/travis/nubs/sensible.svg?style=flat)](https://travis-ci.org/nubs/sensible)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/nubs/sensible.svg?style=flat)](https://scrutinizer-ci.com/g/nubs/sensible/)
[![Code Coverage](http://img.shields.io/coveralls/nubs/sensible.svg?style=flat)](https://coveralls.io/r/nubs/sensible)

[![Latest Stable Version](http://img.shields.io/packagist/v/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)
[![Total Downloads](http://img.shields.io/packagist/dt/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)
[![License](http://img.shields.io/packagist/l/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)

[![Dependency Status](https://www.versioneye.com/user/projects/53866d7014c15895cb000053/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53866d7014c15895cb000053)

## Requirements
This library requires PHP 5.4, or newer.

## Installation
This package uses [composer](https://getcomposer.org) so you can just add
`nubs/sensible` as a dependency to your `composer.json` file or execute the
following command:

```bash
composer require nubs/sensible
```<commit_msg>Begin documenting things, including the browser factory.<commit_after># sensible
A PHP library for finding sensible user programs, like editor, pager, and browser.

[![Build Status](http://img.shields.io/travis/nubs/sensible.svg?style=flat)](https://travis-ci.org/nubs/sensible)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/nubs/sensible.svg?style=flat)](https://scrutinizer-ci.com/g/nubs/sensible/)
[![Code Coverage](http://img.shields.io/coveralls/nubs/sensible.svg?style=flat)](https://coveralls.io/r/nubs/sensible)

[![Latest Stable Version](http://img.shields.io/packagist/v/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)
[![Total Downloads](http://img.shields.io/packagist/dt/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)
[![License](http://img.shields.io/packagist/l/nubs/sensible.svg?style=flat)](https://packagist.org/packages/nubs/sensible)

[![Dependency Status](https://www.versioneye.com/user/projects/53866d7014c15895cb000053/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53866d7014c15895cb000053)

## Requirements
This library requires PHP 5.4, or newer.

## Installation
This package uses [composer](https://getcomposer.org) so you can just add
`nubs/sensible` as a dependency to your `composer.json` file or execute the
following command:

```bash
composer require nubs/sensible
```

## Supported Program Types
This library supports opening a text editor (like vim), a pager (like more),
and a browser (like firefox).

## Program Factories
The recommended way to initialize one of the supported program loaders is to
use the included factories.

### Browser Factory
The browser factory uses a command locator (via [which]) to determine which
browsers are available.  The default list of browsers is
* sensible-browser
* firefox
* chromium-browser
* chrome
* elinks

A simple example for creating a browser object:
```php
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$browserFactory = new Nubs\Sensible\CommandFactory\BrowserFactory(
    $commandLocatorFactory->create()
);
$browser = $browserFactory->create();
```

If you want to override the default list of browsers:
```php
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$browserFactory = new Nubs\Sensible\CommandFactory\BrowserFactory(
    $commandLocatorFactory->create(),
    ['my-favorite-browser', 'some-fallback-browser']
);
$browser = $browserFactory->create();
```

[which]: https://github.com/nubs/which
{'fraction_non_alphanumeric': 0.15152290760174048, 'fraction_numerical': 0.021499872024571282, 'mean_word_length': 5.966131907308378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 19, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4750854', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1280, 'n_words': 246}