Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Feb 17, 2014
2 parents 31a7266 + 558a7d9 commit 9381d6e
Show file tree
Hide file tree
Showing 14 changed files with 1,235 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .travis.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3G+wU0c9r9fKxnWsHSpwKNAJMUVBAyqG3pkflpHJ8grfe/qJb5Od0HyW/IJHRcm8FoUtmz46AK3u/Xup34cah+6+8H7IR4TrW8/5YNLv7k8mAAN3LqQgP8K0kcdUgr9DibWRbhNLAHHZxMD0FXELWfxotj92XJiT5aNV+JjyQug=
ZZocT3FEPwogN5Qsw69w6hqI/xfUeaP1LqKmFVujuMFDaX8xuNrYWHtyRCXemGfcefFqHGlVyGwORSivKI4TLeE1yDNGcJ1+AAAslC4eIAXi96Mm/RKgSR2Umul+JK7afI8XqxEnZLqmNs/sUCZvnr/93BhA9UTgcmj9LSgqOYM=
45 changes: 28 additions & 17 deletions .travis.install
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
#!/usr/bin/env php
<?php
/**
* This script is executed before composer dependencies are installed,
* and as such must be included in each project as part of the skeleton.
*/
if ($token = getenv('ARCHER_TOKEN')) {
$config = array(
'config' => array(
'github-oauth' => array('github.com' => $token)
)
);
// Update composer to the latest version ...
passthru('composer self-update --no-interaction');

$file = '~/.composer/config.json';
$dir = dirname($file);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
file_put_contents($file, json_encode($config));
// Build a composer config that uses the GitHub OAuth token if it is available ...
$config = array(
'config' => array(
'notify-on-install' => false
)
);

if ($token = getenv('ARCHER_TOKEN')) {
$config['config']['github-oauth'] = array(
'github.com' => $token
);
$composerFlags = '--prefer-dist';
} else {
$composerFlags = '--prefer-source';
}

passthru('composer install --dev --no-progress --no-interaction --ansi ' . $composerFlags);
$file = '~/.composer/config.json';
$dir = dirname($file);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
file_put_contents($file, json_encode($config));

// Display some information about GitHub rate limiting ...
if ($token) {
passthru('curl -s -i -H "Authorization: token $ARCHER_TOKEN" https://api.github.com | grep "^X-RateLimit"');
}

// Install composer dependencies ...
$exitCode = 0;
passthru('composer install --dev --no-progress --no-interaction --ansi ' . $composerFlags, $exitCode);
exit($exitCode);
27 changes: 8 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
#
# This is the default Travis CI configuration.
#
# It uses a GitHub OAuth token when fetching composer dependencies
# to avoid IP-based API throttling.
#
# It also allows publication of artifacts via an additional build.
#
language: php

php:
- 5.3
- 5.4
- 5.5
php: ["5.3", "5.4", "5.5", "hhvm"]

matrix:
allow_failures:
- php: hhvm

env:
global:
- ARCHER_PUBLISH_VERSION=5.4
- secure: "3G+wU0c9r9fKxnWsHSpwKNAJMUVBAyqG3pkflpHJ8grfe/qJb5Od0HyW/IJHRcm8FoUtmz46AK3u/Xup34cah+6+8H7IR4TrW8/5YNLv7k8mAAN3LqQgP8K0kcdUgr9DibWRbhNLAHHZxMD0FXELWfxotj92XJiT5aNV+JjyQug="
- ARCHER_PUBLISH_VERSION=5.5
- secure: "ZZocT3FEPwogN5Qsw69w6hqI/xfUeaP1LqKmFVujuMFDaX8xuNrYWHtyRCXemGfcefFqHGlVyGwORSivKI4TLeE1yDNGcJ1+AAAslC4eIAXi96Mm/RKgSR2Umul+JK7afI8XqxEnZLqmNs/sUCZvnr/93BhA9UTgcmj9LSgqOYM="

install:
- ./.travis.install

script:
- ./vendor/bin/archer travis:build

matrix:
# PHP 5.5 is still in alpha, so ignore build failures.
allow_failures:
- php: 5.5
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# PHP-LCS changelog

### 1.0.3
## 2.0.0 (2014-02-17)

* [Archer](https://github.com/IcecaveStudios/archer) integration
* Implemented changelog
- **[BC BREAK]** Moved to Eloquent
- **[NEW]** Customizable comparator
- **[NEW]** API documentation

## 1.0.3 (2013-03-04)

- **[NEW]** [Archer](https://github.com/IcecaveStudios/archer) integration
- **[NEW]** Implemented changelog
25 changes: 14 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ changes.

### Code style

All PHP code must adhere to the
[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
standards.
All PHP code must adhere to the [PSR-2] standards.

### Branching and pull requests

As a guideline, please follow this process:

1. [Fork the repository](https://help.github.com/articles/fork-a-repo).
1. [Fork the repository].
2. Create a topic branch for the change:
* New features should branch from **develop**.
* Bug fixes to existing versions should branch from **master**.
* Please ensure the branch is clearly labelled as a feature or fix.
- New features should branch from **develop**.
- Bug fixes to existing versions should branch from **master**.
- Please ensure the branch is clearly labelled as a feature or fix.
3. Make the relevant changes.
4. [Squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages)
commits if necessary.
4. [Squash] commits if necessary.
4. Submit a pull request to the **develop** branch.

Please note this is a general guideline only. For more information on the
branching structure please see the
[git-flow cheatsheet](http://danielkummer.github.com/git-flow-cheatsheet/).
branching structure please see the [git-flow cheatsheet].

<!-- References -->

[Fork the repository](https://help.github.com/articles/fork-a-repo)
[git-flow cheatsheet](http://danielkummer.github.com/git-flow-cheatsheet/)
[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
[Squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2013 Erin Millard
Copyright © 2014 Erin Millard

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
101 changes: 50 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,72 @@

*An implementation of the 'longest common subsequence' algorithm for PHP.*

[![Build Status]](http://travis-ci.org/ezzatron/php-lcs)
[![Test Coverage]](http://ezzatron.com/php-lcs/artifacts/tests/coverage/)
[![The most recent stable version is 2.0.0][version-image]][Semantic versioning]
[![Current build status image][build-image]][Current build status]
[![Current coverage status image][coverage-image]][Current coverage status]

## Installation
## Installation and documentation

Available as [Composer](http://getcomposer.org/) package
[ezzatron/php-lcs](https://packagist.org/packages/ezzatron/php-lcs).
- Available as [Composer] package [eloquent/lcs].
- [API documentation] available.

## What is PHP-LCS?

PHP-LCS is a PHP implementation of an algorithm to solve the 'longest common
*PHP-LCS* is a PHP implementation of an algorithm to solve the 'longest common
subsequence' problem.

From [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem):
From [Wikipedia - longest common subsequence problem]:

> The **longest common subsequence (LCS) problem** is to find the longest
> [subsequence](http://en.wikipedia.org/wiki/Subsequence) common to all
> sequences in a set of sequences (often just two). Note that subsequence is
> different from a substring, see
> [substring vs. subsequence](http://en.wikipedia.org/wiki/Subsequence#Substring_vs._subsequence).
> It is a classic [computer science](http://en.wikipedia.org/wiki/Computer_science)
> problem, the basis of [file comparison](http://en.wikipedia.org/wiki/File_comparison)
> programs such as [diff](http://en.wikipedia.org/wiki/Diff), and has
> applications in [bioinformatics](http://en.wikipedia.org/wiki/Bioinformatics).
> [subsequence] common to all sequences in a set of sequences (often just two).
> Note that subsequence is different from a substring, see [substring vs.
> subsequence]. It is a classic [computer science] problem, the basis of [file
> comparison] programs such as [diff], and has applications in [bioinformatics].
## Usage

```php
use Ezzatron\LCS\LCSSolver;
use Eloquent\Lcs\LcsSolver;

$solver = new LCSSolver;
$solver = new LcsSolver;

$left = array(
'B',
'A',
'N',
'A',
'N',
'A',
);
$right = array(
'A',
'T',
'A',
'N',
'A',
);
$expectedLCS = array(
'A',
'A',
'N',
'A',
);
$sequenceA = array('B', 'A', 'N', 'A', 'N', 'A');
$sequenceB = array('A', 'T', 'A', 'N', 'A');

$LCS = $solver->longestCommonSubsequence(
$left,
$right
);
// calculates the LCS to be array('A', 'A', 'N', 'A')
$lcs = $solver->longestCommonSubsequence($sequenceA, $sequenceB);
```

Elements in sequences can be anything. By default, sequence members are compared
using the `===` operator. To customize this comparison, simply construct the
solver with a custom comparator, like so:

if ($LCS === $expectedLCS) {
echo 'LCS solver is working.';
} else {
echo 'LCS solver is not working.';
}
// the above outputs 'LCS solver is working.'
```php
use Eloquent\Lcs\LcsSolver;

$solver = new LcsSolver(
function ($left, $right) {
// return true if $left and $right are equal
}
);
```

<!-- references -->
[Build Status]: https://raw.github.com/ezzatron/php-lcs/gh-pages/artifacts/images/icecave/regular/build-status.png
[Test Coverage]: https://raw.github.com/ezzatron/php-lcs/gh-pages/artifacts/images/icecave/regular/coverage.png
<!-- References -->

[bioinformatics]: http://en.wikipedia.org/wiki/Bioinformatics
[computer science]: http://en.wikipedia.org/wiki/Computer_science
[diff]: http://en.wikipedia.org/wiki/Diff
[file comparison]: http://en.wikipedia.org/wiki/File_comparison
[subsequence]: http://en.wikipedia.org/wiki/Subsequence
[substring vs. subsequence]: http://en.wikipedia.org/wiki/Subsequence#Substring_vs._subsequence
[Wikipedia - longest common subsequence problem]: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem

[API documentation]: http://lqnt.co/php-lcs/artifacts/documentation/api/
[Composer]: http://getcomposer.org/
[build-image]: http://img.shields.io/travis/eloquent/php-lcs/develop.svg "Current build status for the develop branch"
[Current build status]: https://travis-ci.org/eloquent/php-lcs
[coverage-image]: http://img.shields.io/coveralls/eloquent/php-lcs/develop.svg "Current test coverage for the develop branch"
[Current coverage status]: https://coveralls.io/r/eloquent/php-lcs
[eloquent/lcs]: https://packagist.org/packages/eloquent/lcs
[Semantic versioning]: http://semver.org/
[version-image]: http://img.shields.io/:semver-2.0.0-brightgreen.svg "This project uses semantic versioning"
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ezzatron/php-lcs",
"name": "eloquent/lcs",
"description": "An implementation of the 'longest common subsequence' algorithm for PHP.",
"keywords": ["longest","common","subsequence","sequence","diff","algorithm"],
"homepage": "https://github.com/ezzatron/php-lcs",
"keywords": ["longest", "common", "subsequence", "sequence", "diff", "algorithm"],
"homepage": "https://github.com/eloquent/php-lcs",
"license": "MIT",
"authors": [
{
Expand All @@ -12,14 +12,14 @@
}
],
"require": {
"php": ">=5"
"php": ">=5.3"
},
"require-dev": {
"icecave/archer": "~0.2"
"icecave/archer": "~1"
},
"autoload": {
"psr-0": {
"Ezzatron\\LCS": "src"
"psr-4": {
"Eloquent\\Lcs\\": "src"
}
}
}
Loading

0 comments on commit 9381d6e

Please sign in to comment.