Skip to content

Commit

Permalink
Improve URI Interfaces
Browse files Browse the repository at this point in the history
- Improve Component interface
- Simplify Path Interface
- Remove extra Interfaces
  • Loading branch information
nyamsprod committed Oct 17, 2016
1 parent 04bdfd1 commit d71f465
Show file tree
Hide file tree
Showing 14 changed files with 441 additions and 41 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
5 changes: 0 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
/.github export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/README.md export-ignore
/scrutinizer.yml export-ignore
/CHANGELOG.md export-ignore
/CONDUCT.md export-ignore
/phpunit.xml export-ignore
/test export-ignore
49 changes: 49 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

## Bug Report

We accept bug reports via issues created on [Github](https://github.com/thephpleague/uri-interfaces/issues).

### Prior to submitting your report

- **Always search the issue or pull request list first** - The odds are good that if you've found a problem, someone else has found it, too.

- **Always try the [master branch](https://github.com/thephpleague/uri-interfaces)** - to see if the reported bug has not already been fixed.

### When submitting your report

- **Open a new bug report for each issue.**

- **Write a clear summary in english** - A good summary should quickly and uniquely identify a bug report. It should explain the problem, not your suggested solution.

- **Be brief, but don't leave any important details out** - Tell us what you did, what you expected to happen, and what happened. Do not forget to mention your PHP version, the OS Platform and the package version you were using.

## Pull Request

We accept contributions via Pull Requests on [Github](https://github.com/thephpleague/uri-interfaces/pull).

- **[PSR-2 Coding Standard](http://www.php-fig.org/psr/psr-2/)** - Your patch won't be accepted if it doesn't pass the package coding style test suite.

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the README and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow semver. Randomly breaking public APIs is not an option.

- **Create topic branches** - Don't ask us to pull from your master branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.


## Running Tests

``` bash
$ phpunit
```


**Happy coding**!
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Issue summary

_(Please explain in plain english your issue)_

### System informations

_(In case of a bug report Please complete the table below)_

| Information | Description |
|--------------|---------|
| League\Uri\Interfaces version | |
| PHP/HHVM version | |
| OS Platform | |


## Standalone code, or other way to reproduce the problem

_(Please complete the text below to help us fix the issue)_

### Expected result

### Actual result
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Introduction

_(Please explain the library current status regarding your PR.)_

## Proposal

### Describe the new/upated/fixed feature

_(Please explain your proposal. If this is a issue fix, please provide the issue number. If you have not yet created an issue, please do so now)_

### Backward Incompatible Changes

_(Describe if they exists BC break)_

### Targeted release version

_(Indicate the release version targeted for your PR)_

### PR Impact

_(Describe the PR impact on the current public API)_

## Open issues

_(Describe possible open issues and/or future scope if any depending on this RFC acceptance)_
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$header = <<<'EOF'
This file is part of Bakame\Uri\Interfaces, a common URI Interface package
This file is part of League\Uri\Interfaces, a common URI Interface package
@copyright 2016 Ignace Nyamagana Butera. All rights reserved
@license MIT See LICENSE.md at the root of the project for more info
Expand Down
44 changes: 41 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
# Changelog

All Notable changes to `Bakame\Uri\Interfaces` will be documented in this file
All Notable changes to `League\Uri\Interfaces` will be documented in this file

## Next
## 0.1.0 - 2016-10-17

- first release
### Added

- `League\Uri\Interfaces\Component::getContent`
- `League\Uri\Interfaces\Component::withContent`
- `League\Uri\Interfaces\Component::isDefined`

### Fixed

- Renamed `League\Uri\Interfaces\Collection` to `League\Uri\Interfaces\CollectionComponent`
- Renamed `League\Uri\Interfaces\Path` to `League\Uri\Interfaces\PathComponent`

### Deprecated

- None

### Removed

- `League\Uri\Interfaces\UriPart`
- `League\Uri\Interfaces\HierarchicalComponent`
- `League\Uri\Interfaces\Scheme`
- `League\Uri\Interfaces\User`
- `League\Uri\Interfaces\Pass`
- `League\Uri\Interfaces\UserInfo`
- `League\Uri\Interfaces\Host`
- `League\Uri\Interfaces\Port`
- `League\Uri\Interfaces\Path::withoutEmptySegments`
- `League\Uri\Interfaces\Path::hasTrailingSlash`
- `League\Uri\Interfaces\Path::withTrailingSlash`
- `League\Uri\Interfaces\Path::withoutTrailingSlash`
- `League\Uri\Interfaces\Path::getTypecode`
- `League\Uri\Interfaces\Path::withTypecode`
- `League\Uri\Interfaces\Path::FTP_TYPE_ASCII`
- `League\Uri\Interfaces\Path::FTP_TYPE_BINARY`
- `League\Uri\Interfaces\Path::FTP_TYPE_DIRECTORY`
- `League\Uri\Interfaces\Path::FTP_TYPE_EMPTY`
- `League\Uri\Interfaces\HierarchicalPath`
- `League\Uri\Interfaces\DataPath`
- `League\Uri\Interfaces\Query`
- `League\Uri\Interfaces\Fragment`
22 changes: 22 additions & 0 deletions CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Uri Interfaces
=======

This package contains Interfaces to be use to represents URI objects and URI components objects according to [RFC 3986](http://tools.ietf.org/html/rfc3986).

System Requirements
-------

You need:

- **PHP >= 5.3.0** but the latest stable version of PHP is recommended

Install
--------

```
$ composer require league/uri-interfaces
```

Documentation
--------

The following interfaces are defined:

### 1. League\Uri\Interfaces\Component

This interface models URI Components as specified in [RFC 3986](http://tools.ietf.org/html/rfc3986). This interface provides methods for interacting with any type of URI components in a predicable way. It also specifies a `__toString()` method for casting the modeled URI component to its string representation.


### 1.2 League\Uri\Interfaces\CollectionComponent

This interface extends:

- The `Countable` Interface
- The `IteratorAggregate` Interface
- The `Component` Interface

And provides extra methods for filtering and removing items from such components based on their index or values.

### 1.3 League\Uri\Interfaces\PathComponent

This interface extends the Component interface and provides extra methods to represent any type of Path component.

### 2. League\Uri\Interfaces\Uri

Uri interface models generic URIs as specified in [RFC 3986](http://tools.ietf.org/html/rfc3986). The interface provides methods for interacting with the various URI parts, which will obviate the need for repeated parsing of the URI. It also specifies a `__toString()` method for casting the modeled URI to its string representation. This interface exposes the same methods as `Psr\Http\Message\UriInterface`. But, unlike the `UriInterface`, this interface does not require the `http` and `https` schemes to be supported. The supported schemes are determined by the concrete class which implements this interface.

Contributing
-------

Contributions are welcome and will be fully credited. Please see [CONTRIBUTING](.github/CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
-------

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits
-------

- [ignace nyamagana butera](https://github.com/nyamsprod)
- [All Contributors](https://github.com/thephpleague/uri/contributors)

License
-------

The MIT License (MIT). Please see [License File](LICENSE) for more information.
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "bakame/uri-interfaces",
"name": "league/uri-interfaces",
"type": "library",
"description" : "Common interface for URI",
"keywords": ["url", "uri", "rfc3986", "parse_url", "http", "https", "ws", "ftp", "data-uri", "file"],
"keywords": [
"url",
"uri",
"rfc3986",
"rfc3987"
],
"license": "MIT",
"homepage": "http://github.com/bakame-php/uri-interfaces",
"homepage": "http://github.com/thephpleague/uri-interfaces",
"authors": [
{
"name" : "Ignace Nyamagana Butera",
Expand All @@ -20,7 +25,7 @@
},
"autoload": {
"psr-4": {
"Bakame\\Uri\\Interfaces\\": "src/"
"League\\Uri\\Interfaces\\": "src/"
}
},
"scripts": {
Expand Down
83 changes: 83 additions & 0 deletions src/CollectionComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* League.Uri (http://uri.thephpleague.com)
*
* @package League\Uri
* @subpackage League\Uri\Interfaces
* @author Ignace Nyamagana Butera <[email protected]>
* @copyright 2016 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri-interfaces/blob/master/LICENSE (MIT License)
* @version 1.0.0
* @link https://github.com/thephpleague/uri-interfaces/
*/
namespace League\Uri\Interfaces;

use Countable;
use InvalidArgumentException;
use IteratorAggregate;

/**
* Value object representing a Collection.
*
* Instances of this interface are considered immutable; all methods that
* might change state MUST be implemented such that they retain the internal
* state of the current instance and return an instance that contains the
* changed state.
*
* @package League\Uri
* @subpackage League\Uri\Interfaces
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
interface CollectionComponent extends Countable, Component, IteratorAggregate
{
/**
* Returns the component $keys.
*
* Returns the component $keys. If a value is specified
* only the $keys associated with the given value will be returned
*
* @return array
*/
public function keys();

/**
* Returns whether the given key exists in the current instance
*
* @param string $key
*
* @return bool
*/
public function hasKey($key);

/**
* Returns an instance with filtered elements
*
* Iterates over each value in the collection passing them to the callback function.
* If the callback function returns true, the current value from the collection is returned
* into the returned new instance.
*
* This method MUST retain the state of the current instance, and return
* an instance that contains the modified component
*
* @param callable $callable the callback function to use
* @param int $flag flag to determine what argument are sent to callback
*
* @throws InvalidArgumentException for transformations that would result in a invalid object.
*
* @return static
*/
public function filter(callable $callable, $flag = 0);

/**
* Returns an instance without the specified keys
*
* This method MUST retain the state of the current instance, and return
* an instance that contains the modified component
*
* @param array $keys the list of keys to remove from the collection
*
* @return static
*/
public function without(array $keys);
}
Loading

0 comments on commit d71f465

Please sign in to comment.