joanfont / contexts

a PHP library that emulates Python's `with` statement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contexts

Build Status codecov

a PHP library that emulates Python's with statement

Example

<?php
use function Contexts\with;
use Contexts\Context;

class TestContext implements Context
{
  public function enter()
  {
    print("Before executing function\n");
  }

  public function quit($exception)
  {
    print("After executing function\n");
  }
}

$context = new TestContext;
with($context, function() {
  print("Executing function\n");
});

?>

Testing

phpunit tests

Credits

About

a PHP library that emulates Python's `with` statement


Languages

Language:PHP 100.0%