Skip to content

Commit

Permalink
Implemented... everything.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Oct 7, 2015
0 parents commit 7ac29f5
Show file tree
Hide file tree
Showing 15 changed files with 2,247 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# archer start
.gitattributes export-ignore
.gitignore export-ignore
.travis.* export-ignore
.archer.* export-ignore
test export-ignore
# archer end
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# archer start
/artifacts/
/vendor/
# archer end
65 changes: 65 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
->exclude(
array(
'artifacts',
'assets',
'bower_components',
'build',
'node_modules',
'src-web',
'vendor',
)
);

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers(
array(
// symfony
'blankline_after_open_tag',
'duplicate_semicolon',
'extra_empty_lines',
'include',
'join_function',
'list_commas',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'new_with_braces',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'object_operator',
'operators_spaces',
'phpdoc_indent',
'phpdoc_params',
'phpdoc_short_description',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_type_to_var',
'phpdoc_var_without_name',
'pre_increment',
'remove_leading_slash_use',
'remove_lines_between_uses',
'return',
'self_accessor',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'standardize_not_equal',
'ternary_spaces',
'trim_array_spaces',
'unary_operators_spaces',
'unused_use',
'whitespacy_lines',

// contrib
'concat_with_spaces',
'multiline_spaces_before_semicolon',
'ordered_use',
)
)
->finder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Flip Changelog
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contributing

**Flip** is open source software; contributions from the community are
encouraged. Please take a moment to read these guidelines before submitting
changes.

## Code style

All PHP code must adhere to the [PSR-2] standards.

[psr-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md

## Branching and pull requests

As a guideline, please follow this process:

1. [Fork the repository].
2. Create a topic branch for the change, branching from **develop**
(`git checkout -b branch-name develop`).
3. Make the relevant changes.
4. [Squash] commits if necessary (`git rebase -i develop`).
5. Submit a pull request to the **develop** branch.

[fork the repository]: https://help.github.com/articles/fork-a-repo
[squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages

## Tests

- Run the tests with `vendor/bin/archer`.
- Generate a coverage report with `vendor/bin/archer c`. The coverage report
will be created at `artifacts/tests/coverage/index.html`.
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# License

**© 2014, [James Harris]**

[james harris]: https://github.com/jmalloc

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Flip

[![The most recent stable version is 0.0.0][version-image]][semantic versioning]
[![Current build status image][build-image]][current build status]
[![Current coverage status image][coverage-image]][current coverage status]

[build-image]: http://img.shields.io/travis/IcecaveStudios/flip/develop.svg?style=flat-square "Current build status for the develop branch"
[current build status]: https://travis-ci.org/IcecaveStudios/flip
[coverage-image]: https://img.shields.io/codecov/c/github/IcecaveStudios/flip/develop.svg?style=flat-square "Current test coverage for the develop branch"
[current coverage status]: https://coveralls.io/r/IcecaveStudios/flip
[semantic versioning]: http://semver.org/
[version-image]: http://img.shields.io/:semver-0.0.0-red.svg?style=flat-square "This project uses semantic versioning"

**Flip** is a simple PHP library for accepting sets of boolean options as input
to functions.

- Install via [Composer] package [icecave/flip]
- Read the [API documentation]

[api documentation]: http://icecavestudios.github.io/flip/artifacts/documentation/api/
[composer]: http://getcomposer.org/
[icecave/flip]: https://packagist.org/packages/icecave/flip

## Example

First the valid options are defined by declaring a class that extends from
`AbstractOptions`.

```php
use Icecave\Flip\AbstractOptions;

final class MyOptions extends AbstractOptions
{
const FOO = 'foo';
const BAR = 'bar';
}
```

Functions that accept the options use the `build()` method to create an
`OptionCollection` that holds the state of the passed options.

```php
function printOptions(array $options)
{
$options = MyOptions::build($options);

if ($options[MyOptions::FOO()]) {
echo 'Foo is enabled!';
} else {
echo 'Foo is disabled!';
}

if ($options[MyOptions::BAR()]) {
echo 'Bar is enabled!';
} else {
echo 'Bar is disabled!';
}
}
```

When calling the function, options are passed as an array mapping the option
value to a boolean.

```php
$options = [
MyOptions::FOO => true,
];

printOptions($options);
```

Which will output:
```console
Foo is enabled!
Bar is disabled!
```

An `InvalidArgumentException` is thrown if the options array passed to `build()`
contains keys that are not defined in the `MyOptions` class.

## Contact us

- Follow [@IcecaveStudios] on Twitter
- Visit the [Icecave Studios website]

[@icecavestudios]: https://twitter.com/IcecaveStudios
[icecave studios website]: http://icecave.com.au/
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "icecave/flip",
"description": "Simple, strict, explicit boolean options.",
"keywords": [
"flag",
"option",
"bit",
"boolean"
],
"homepage": "https://github.com/IcecaveStudios/flip",
"license": "MIT",
"authors": [
{
"name": "James Harris",
"email": "[email protected]",
"homepage": "https://github.com/jmalloc"
}
],
"require": {
"php": ">=5.6",
"icecave/isolator": "~2",
"eloquent/enumeration": "^5"
},
"require-dev": {
"icecave/archer": "~1",
"eloquent/phony": "^0.3"
},
"autoload": {
"psr-4": {
"Icecave\\Flip\\": "src"
}
},
"extra": {
"branch-alias": {
"dev-develop": "0.1.x-dev"
}
}
}
Loading

0 comments on commit 7ac29f5

Please sign in to comment.