Skip to content

Commit

Permalink
Documentation for Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Nov 10, 2017
1 parent f94c3ea commit e360c73
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ $loop->run();
purposes.
3. The loop is run with a single `$loop->run()` call at the end of the program.

## Factory

The `Factory` class exists as a convenient way to pick the best available
[loop implementation)(#loop-implementation).

The `create(): LoopInterface` method can be used to create a new loop
instance:

```php
$loop = React\EventLoop\Factory::create();
```

This method always returns an instance implementing `LoopInterface`,
the actual loop implementation is an implementation detail.

This method should usually only be called once at the beginning of the program.

## Loop implementations

In addition to the interface there are the following implementations provided:
Expand Down
17 changes: 17 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@

namespace React\EventLoop;

/**
* The `Factory` class exists as a convenient way to pick the best available loop implementation.
*/
class Factory
{
/**
* Creates a new loop instance
*
* ```php
* $loop = React\EventLoop\Factory::create();
* ```
*
* This method always returns an instance implementing `LoopInterface`,
* the actual loop implementation is an implementation detail.
*
* This method should usually only be called once at the beginning of the program.
*
* @return LoopInterface
*/
public static function create()
{
// @codeCoverageIgnoreStart
Expand Down

0 comments on commit e360c73

Please sign in to comment.