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

Commit fcc9141

Browse files
committed
Repository maintenance.
1 parent 31a7266 commit fcc9141

14 files changed

+1234
-358
lines changed

.travis.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3G+wU0c9r9fKxnWsHSpwKNAJMUVBAyqG3pkflpHJ8grfe/qJb5Od0HyW/IJHRcm8FoUtmz46AK3u/Xup34cah+6+8H7IR4TrW8/5YNLv7k8mAAN3LqQgP8K0kcdUgr9DibWRbhNLAHHZxMD0FXELWfxotj92XJiT5aNV+JjyQug=
1+
QYAsj0sNlPKY/QuRAkupRb4pdQZBNTQ66kcHWrGs04eRrjAVwhBIN5gvpJTnJuLbxGNJePIDu7TjbcnaDyAXoQ5QVWlLZOHOUPinbzrFdMUjDWOPlJjHc00f2o9eDlGENKWKEI3NCLphqaKepOJ6oAvwooCGYkuftUeudEhNQ94=

.travis.install

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
#!/usr/bin/env php
22
<?php
3-
/**
4-
* This script is executed before composer dependencies are installed,
5-
* and as such must be included in each project as part of the skeleton.
6-
*/
7-
if ($token = getenv('ARCHER_TOKEN')) {
8-
$config = array(
9-
'config' => array(
10-
'github-oauth' => array('github.com' => $token)
11-
)
12-
);
3+
// Update composer to the latest version ...
4+
passthru('composer self-update --no-interaction');
135

14-
$file = '~/.composer/config.json';
15-
$dir = dirname($file);
16-
if (!is_dir($dir)) {
17-
mkdir($dir, 0755, true);
18-
}
19-
file_put_contents($file, json_encode($config));
6+
// Build a composer config that uses the GitHub OAuth token if it is available ...
7+
$config = array(
8+
'config' => array(
9+
'notify-on-install' => false
10+
)
11+
);
2012

13+
if ($token = getenv('ARCHER_TOKEN')) {
14+
$config['config']['github-oauth'] = array(
15+
'github.com' => $token
16+
);
2117
$composerFlags = '--prefer-dist';
2218
} else {
2319
$composerFlags = '--prefer-source';
2420
}
2521

26-
passthru('composer install --dev --no-progress --no-interaction --ansi ' . $composerFlags);
22+
$file = '~/.composer/config.json';
23+
$dir = dirname($file);
24+
if (!is_dir($dir)) {
25+
mkdir($dir, 0755, true);
26+
}
27+
file_put_contents($file, json_encode($config));
28+
29+
// Display some information about GitHub rate limiting ...
30+
if ($token) {
31+
passthru('curl -s -i -H "Authorization: token $ARCHER_TOKEN" https://api.github.com | grep "^X-RateLimit"');
32+
}
33+
34+
// Install composer dependencies ...
35+
$exitCode = 0;
36+
passthru('composer install --dev --no-progress --no-interaction --ansi ' . $composerFlags, $exitCode);
37+
exit($exitCode);

.travis.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
#
2-
# This is the default Travis CI configuration.
3-
#
4-
# It uses a GitHub OAuth token when fetching composer dependencies
5-
# to avoid IP-based API throttling.
6-
#
7-
# It also allows publication of artifacts via an additional build.
8-
#
91
language: php
102

11-
php:
12-
- 5.3
13-
- 5.4
14-
- 5.5
3+
php: ["5.3", "5.4", "5.5", "hhvm"]
4+
5+
matrix:
6+
allow_failures:
7+
- php: hhvm
158

169
env:
1710
global:
18-
- ARCHER_PUBLISH_VERSION=5.4
19-
- secure: "3G+wU0c9r9fKxnWsHSpwKNAJMUVBAyqG3pkflpHJ8grfe/qJb5Od0HyW/IJHRcm8FoUtmz46AK3u/Xup34cah+6+8H7IR4TrW8/5YNLv7k8mAAN3LqQgP8K0kcdUgr9DibWRbhNLAHHZxMD0FXELWfxotj92XJiT5aNV+JjyQug="
11+
- ARCHER_PUBLISH_VERSION=5.5
12+
- secure: "QYAsj0sNlPKY/QuRAkupRb4pdQZBNTQ66kcHWrGs04eRrjAVwhBIN5gvpJTnJuLbxGNJePIDu7TjbcnaDyAXoQ5QVWlLZOHOUPinbzrFdMUjDWOPlJjHc00f2o9eDlGENKWKEI3NCLphqaKepOJ6oAvwooCGYkuftUeudEhNQ94="
2013

2114
install:
2215
- ./.travis.install
16+
2317
script:
2418
- ./vendor/bin/archer travis:build
25-
26-
matrix:
27-
# PHP 5.5 is still in alpha, so ignore build failures.
28-
allow_failures:
29-
- php: 5.5

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# PHP-LCS changelog
22

3-
### 1.0.3
3+
## 2.0.0 (unrelease)
44

5-
* [Archer](https://github.com/IcecaveStudios/archer) integration
6-
* Implemented changelog
5+
- **[BC BREAK]** Moved to Eloquent
6+
- **[NEW]** Customizable comparator
7+
- **[NEW]** API documentation
8+
9+
## 1.0.3 (2013-03-04)
10+
11+
- **[NEW]** [Archer](https://github.com/IcecaveStudios/archer) integration
12+
- **[NEW]** Implemented changelog

CONTRIBUTING.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ changes.
66

77
### Code style
88

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

1311
### Branching and pull requests
1412

1513
As a guideline, please follow this process:
1614

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

2724
Please note this is a general guideline only. For more information on the
28-
branching structure please see the
29-
[git-flow cheatsheet](http://danielkummer.github.com/git-flow-cheatsheet/).
25+
branching structure please see the [git-flow cheatsheet].
26+
27+
<!-- References -->
28+
29+
[Fork the repository](https://help.github.com/articles/fork-a-repo)
30+
[git-flow cheatsheet](http://danielkummer.github.com/git-flow-cheatsheet/)
31+
[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
32+
[Squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2013 Erin Millard
1+
Copyright © 2014 Erin Millard
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,72 @@
22

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

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

8-
## Installation
9+
## Installation and documentation
910

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

1314
## What is PHP-LCS?
1415

15-
PHP-LCS is a PHP implementation of an algorithm to solve the 'longest common
16+
*PHP-LCS* is a PHP implementation of an algorithm to solve the 'longest common
1617
subsequence' problem.
1718

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

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

3229
```php
33-
use Ezzatron\LCS\LCSSolver;
30+
use Eloquent\Lcs\LcsSolver;
3431

35-
$solver = new LCSSolver;
32+
$solver = new LcsSolver;
3633

37-
$left = array(
38-
'B',
39-
'A',
40-
'N',
41-
'A',
42-
'N',
43-
'A',
44-
);
45-
$right = array(
46-
'A',
47-
'T',
48-
'A',
49-
'N',
50-
'A',
51-
);
52-
$expectedLCS = array(
53-
'A',
54-
'A',
55-
'N',
56-
'A',
57-
);
34+
$sequenceA = array('B', 'A', 'N', 'A', 'N', 'A');
35+
$sequenceB = array('A', 'T', 'A', 'N', 'A');
5836

59-
$LCS = $solver->longestCommonSubsequence(
60-
$left,
61-
$right
62-
);
37+
// calculates correct LCS of array('A', 'A', 'N', 'A')
38+
$lcs = $solver->longestCommonSubsequence($sequenceA, $sequenceB);
39+
```
40+
41+
Elements in sequences can be anything. By default, sequence members are compared
42+
using the `===` operator. To customize this comparison, simply construct the
43+
solver with a custom comparator, like so:
6344

64-
if ($LCS === $expectedLCS) {
65-
echo 'LCS solver is working.';
66-
} else {
67-
echo 'LCS solver is not working.';
68-
}
69-
// the above outputs 'LCS solver is working.'
7045
```
46+
use Eloquent\Lcs\LcsSolver;
47+
48+
$solver = new LcsSolver(
49+
function ($left, $right) {
50+
// return true if $left and $right are equal
51+
}
52+
);
53+
```
54+
55+
<!-- References -->
56+
57+
[bioinformatics]: http://en.wikipedia.org/wiki/Bioinformatics
58+
[computer science]: http://en.wikipedia.org/wiki/Computer_science
59+
[diff]: http://en.wikipedia.org/wiki/Diff
60+
[file comparison]: http://en.wikipedia.org/wiki/File_comparison
61+
[subsequence]: http://en.wikipedia.org/wiki/Subsequence
62+
[substring vs. subsequence]: http://en.wikipedia.org/wiki/Subsequence#Substring_vs._subsequence
63+
[Wikipedia - longest common subsequence problem]: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
7164

72-
<!-- references -->
73-
[Build Status]: https://raw.github.com/ezzatron/php-lcs/gh-pages/artifacts/images/icecave/regular/build-status.png
74-
[Test Coverage]: https://raw.github.com/ezzatron/php-lcs/gh-pages/artifacts/images/icecave/regular/coverage.png
65+
[API documentation]: http://lqnt.co/php-lcs/artifacts/documentation/api/
66+
[Composer]: http://getcomposer.org/
67+
[build-image]: http://img.shields.io/travis/eloquent/php-lcs/develop.svg "Current build status for the develop branch"
68+
[Current build status]: https://travis-ci.org/eloquent/php-lcs
69+
[coverage-image]: http://img.shields.io/coveralls/eloquent/php-lcs/develop.svg "Current test coverage for the develop branch"
70+
[Current coverage status]: https://coveralls.io/r/eloquent/php-lcs
71+
[eloquent/php-lcs]: https://packagist.org/packages/eloquent/php-lcs
72+
[Semantic versioning]: http://semver.org/
73+
[version-image]: http://img.shields.io/:semver-1.0.3-brightgreen.svg "This project uses semantic versioning"

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "ezzatron/php-lcs",
2+
"name": "eloquent/php-lcs",
33
"description": "An implementation of the 'longest common subsequence' algorithm for PHP.",
4-
"keywords": ["longest","common","subsequence","sequence","diff","algorithm"],
4+
"keywords": ["longest", "common", "subsequence", "sequence", "diff", "algorithm"],
55
"homepage": "https://github.com/ezzatron/php-lcs",
66
"license": "MIT",
77
"authors": [
@@ -12,14 +12,14 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=5"
15+
"php": ">=5.3"
1616
},
1717
"require-dev": {
18-
"icecave/archer": "~0.2"
18+
"icecave/archer": "~1"
1919
},
2020
"autoload": {
21-
"psr-0": {
22-
"Ezzatron\\LCS": "src"
21+
"psr-4": {
22+
"Eloquent\\Lcs\\": "src"
2323
}
2424
}
2525
}

0 commit comments

Comments
 (0)