Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ac65ce

Browse filesBrowse files
committed
[Translation] renamed Range to Interval
1 parent 9e50782 commit 4ac65ce
Copy full SHA for 4ac65ce

File tree

Expand file treeCollapse file tree

3 files changed

+24
-22
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+24
-22
lines changed

‎src/Symfony/Component/Translation/Range.php renamed to ‎src/Symfony/Component/Translation/Interval.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Interval.php
+15-13Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
*/
1313

1414
/**
15-
* Range tests if a given number belongs to a given range.
15+
* Tests if a given number belongs to a given math interval.
1616
*
17-
* A range can represent a finite set of numbers:
17+
* An interval can represent a finite set of numbers:
1818
*
1919
* {1,2,3,4}
2020
*
21-
* A range can represent numbers between two numbers:
21+
* An interval can represent numbers between two numbers:
2222
*
2323
* [1, +Inf]
2424
* ]-1,2[
@@ -27,22 +27,24 @@
2727
* The right delimiter can be [ (exclusive) or ] (inclusive).
2828
* Beside numbers, you can use -Inf and +Inf for the infinite.
2929
*
30+
* @see http://en.wikipedia.org/wiki/Interval_%28mathematics%29#The_ISO_notation
31+
*
3032
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
3133
*/
32-
class Range
34+
class Interval
3335
{
3436
/**
35-
* Tests if the given number is in the range.
37+
* Tests if the given number is in the math interval.
3638
*
37-
* @param integer $number A number
38-
* @param string $range A range of numbers
39+
* @param integer $number A number
40+
* @param string $interval An interval
3941
*/
40-
static public function test($number, $range)
42+
static public function test($number, $interval)
4143
{
42-
$range = trim($range);
44+
$interval = trim($interval);
4345

44-
if (!preg_match('/^'.self::getRangeRegexp().'$/x', $range, $matches)) {
45-
throw new \InvalidArgumentException(sprintf('"%s" is not a valid range expression.', $range));
46+
if (!preg_match('/^'.self::getIntervalRegexp().'$/x', $interval, $matches)) {
47+
throw new \InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval));
4648
}
4749

4850
if ($matches[1]) {
@@ -66,11 +68,11 @@ static public function test($number, $range)
6668
}
6769

6870
/**
69-
* Returns a Regexp that matches valid ranges.
71+
* Returns a Regexp that matches valid intervals.
7072
*
7173
* @return string A Regexp (without the delimiters)
7274
*/
73-
static public function getRangeRegexp()
75+
static public function getIntervalRegexp()
7476
{
7577
return <<<EOF
7678
({\s*

‎src/Symfony/Component/Translation/MessageSelector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/MessageSelector.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function choose($message, $number, $locale)
2626
foreach ($parts as $part) {
2727
$part = trim($part);
2828

29-
if (preg_match('/^(?<range>'.Range::getRangeRegexp().')\s+(?<message>.+?)$/x', $part, $matches)) {
30-
$explicitRules[$matches['range']] = $matches['message'];
29+
if (preg_match('/^(?<interval>'.Interval::getIntervalRegexp().')\s+(?<message>.+?)$/x', $part, $matches)) {
30+
$explicitRules[$matches['interval']] = $matches['message'];
3131
} elseif (preg_match('/^\w+\: +(.+)$/', $part, $matches)) {
3232
$standardRules[] = $matches[1];
3333
} else {
@@ -36,8 +36,8 @@ public function choose($message, $number, $locale)
3636
}
3737

3838
// try to match an explicit rule, then fallback to the standard ones
39-
foreach ($explicitRules as $range => $m) {
40-
if (Range::test($number, $range)) {
39+
foreach ($explicitRules as $interval => $m) {
40+
if (Interval::test($number, $interval)) {
4141
return $m;
4242
}
4343
}

‎tests/Symfony/Tests/Component/Translation/RangeTest.php renamed to ‎tests/Symfony/Tests/Component/Translation/IntervalTest.php

Copy file name to clipboardExpand all lines: tests/Symfony/Tests/Component/Translation/IntervalTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111

1212
namespace Symfony\Tests\Component\Translation;
1313

14-
use Symfony\Component\Translation\Range;
14+
use Symfony\Component\Translation\Interval;
1515

16-
class RangeTest extends \PHPUnit_Framework_TestCase
16+
class IntervalTest extends \PHPUnit_Framework_TestCase
1717
{
1818
/**
1919
* @dataProvider getTests
2020
*/
21-
public function testTest($expected, $number, $range)
21+
public function testTest($expected, $number, $interval)
2222
{
23-
$this->assertEquals($expected, Range::test($number, $range));
23+
$this->assertEquals($expected, Interval::test($number, $interval));
2424
}
2525

2626
/**
2727
* @expectedException \InvalidArgumentException
2828
*/
2929
public function testTestException()
3030
{
31-
Range::test(1, 'foobar');
31+
Interval::test(1, 'foobar');
3232
}
3333

3434
public function getTests()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.