Skip to content

Commit d076e51

Browse files
committed
renamed DataFormater to DataFormatter (oups!)
1 parent f1cb4dd commit d076e51

14 files changed

+58
-58
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
2014-01-04:
44

5-
- added DataFormater
5+
- added DataFormatter
66

77
2013-12-29:
88

docs/data_formater.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/data_formatter.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Data Formatter
2+
3+
An instance of `DebugBar\DataFormatter\DataFormatterInterface` is used by collectors to
4+
format data.
5+
6+
The default instance is `DebugBar\DataFormatter\DataFormatter`. This can be modified
7+
using `DebugBar\DataCollector\DataCollector::setDefaultDataFormatter()`.
8+
9+
You can use a custom formater for each collector using `DataCollector::setDataFormatter()`.

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ajax_and_stack.md",
1010
"base_collectors.md",
1111
"bridge_collectors.md",
12-
"data_formater.md",
12+
"data_formatter.md",
1313
"storage.md",
1414
"openhandler.md",
1515
"http_drivers.md",

src/DebugBar/DataCollector/ConfigCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function collect()
4747
$data = array();
4848
foreach ($this->data as $k => $v) {
4949
if (!is_string($v)) {
50-
$v = $this->getDataFormater()->formatVar($v);
50+
$v = $this->getDataFormatter()->formatVar($v);
5151
}
5252
$data[$k] = $v;
5353
}

src/DebugBar/DataCollector/DataCollector.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,56 @@
1010

1111
namespace DebugBar\DataCollector;
1212

13-
use DebugBar\DataFormater\DataFormaterInterface;
14-
use DebugBar\DataFormater\DataFormater;
13+
use DebugBar\DataFormatter\DataFormatterInterface;
14+
use DebugBar\DataFormatter\DataFormatter;
1515

1616
/**
1717
* Abstract class for data collectors
1818
*/
1919
abstract class DataCollector implements DataCollectorInterface
2020
{
21-
private static $defaultDataFormater;
21+
private static $defaultDataFormatter;
2222

2323
protected $dataFormater;
2424

2525
/**
2626
* Sets the default data formater instance used by all collectors subclassing this class
2727
*
28-
* @param DataFormaterInterface $formater
28+
* @param DataFormatterInterface $formater
2929
*/
30-
public static function setDefaultDataFormater(DataFormaterInterface $formater)
30+
public static function setDefaultDataFormatter(DataFormatterInterface $formater)
3131
{
32-
self::$defaultDataFormater = $formater;
32+
self::$defaultDataFormatter = $formater;
3333
}
3434

3535
/**
3636
* Returns the default data formater
3737
*
38-
* @return DataFormaterInterface
38+
* @return DataFormatterInterface
3939
*/
40-
public static function getDefaultDataFormater()
40+
public static function getDefaultDataFormatter()
4141
{
42-
if (self::$defaultDataFormater === null) {
43-
self::$defaultDataFormater = new DataFormater();
42+
if (self::$defaultDataFormatter === null) {
43+
self::$defaultDataFormatter = new DataFormatter();
4444
}
45-
return self::$defaultDataFormater;
45+
return self::$defaultDataFormatter;
4646
}
4747

4848
/**
4949
* Sets the data formater instance used by this collector
5050
*
51-
* @param DataFormaterInterface $formater
51+
* @param DataFormatterInterface $formater
5252
*/
53-
public function setDataFormater(DataFormaterInterface $formater)
53+
public function setDataFormatter(DataFormatterInterface $formater)
5454
{
5555
$this->dataFormater = $formater;
5656
return $this;
5757
}
5858

59-
public function getDataFormater()
59+
public function getDataFormatter()
6060
{
6161
if ($this->dataFormater === null) {
62-
$this->dataFormater = self::getDefaultDataFormater();
62+
$this->dataFormater = self::getDefaultDataFormatter();
6363
}
6464
return $this->dataFormater;
6565
}
@@ -69,22 +69,22 @@ public function getDataFormater()
6969
*/
7070
public function formatVar($var)
7171
{
72-
return $this->getDataFormater()->formatVar($var);
72+
return $this->getDataFormatter()->formatVar($var);
7373
}
7474

7575
/**
7676
* @deprecated
7777
*/
7878
public function formatDuration($seconds)
7979
{
80-
return $this->getDataFormater()->formatDuration($seconds);
80+
return $this->getDataFormatter()->formatDuration($seconds);
8181
}
8282

8383
/**
8484
* @deprecated
8585
*/
8686
public function formatBytes($size, $precision = 2)
8787
{
88-
return $this->getDataFormater()->formatBytes($size, $precision);
88+
return $this->getDataFormatter()->formatBytes($size, $precision);
8989
}
9090
}

src/DebugBar/DataCollector/MemoryCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function collect()
4343
$this->updatePeakUsage();
4444
return array(
4545
'peak_usage' => $this->peakUsage,
46-
'peak_usage_str' => $this->getDataFormater()->formatBytes($this->peakUsage)
46+
'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage)
4747
);
4848
}
4949

src/DebugBar/DataCollector/MessagesCollector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ public function __construct($name = 'messages')
3636
/**
3737
* Sets the data formater instance used by this collector
3838
*
39-
* @param DataFormaterInterface $formater
39+
* @param DataFormatterInterface $formater
4040
*/
41-
public function setDataFormater(DataFormaterInterface $formater)
41+
public function setDataFormatter(DataFormatterInterface $formater)
4242
{
4343
$this->dataFormater = $formater;
4444
return $this;
4545
}
4646

47-
public function getDataFormater()
47+
public function getDataFormatter()
4848
{
4949
if ($this->dataFormater === null) {
50-
$this->dataFormater = DataCollector::getDefaultDataFormater();
50+
$this->dataFormater = DataCollector::getDefaultDataFormatter();
5151
}
5252
return $this->dataFormater;
5353
}
@@ -64,7 +64,7 @@ public function addMessage($message, $label = 'info')
6464
{
6565
$isString = true;
6666
if (!is_string($message)) {
67-
$message = $this->getDataFormater()->formatVar($message);
67+
$message = $this->getDataFormatter()->formatVar($message);
6868
$isString = false;
6969
}
7070
$this->messages[] = array(

src/DebugBar/DataCollector/PDO/PDOCollector.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public function collect()
101101
array_map(function($s) use ($name) { $s['connection'] = $name; return $s; }, $pdodata['statements']));
102102
}
103103

104-
$data['accumulated_duration_str'] = $this->getDataFormater()->formatDuration($data['accumulated_duration']);
105-
$data['memory_usage_str'] = $this->getDataFormater()->formatBytes($data['memory_usage']);
106-
$data['peak_memory_usage_str'] = $this->getDataFormater()->formatBytes($data['peak_memory_usage']);
104+
$data['accumulated_duration_str'] = $this->getDataFormatter()->formatDuration($data['accumulated_duration']);
105+
$data['memory_usage_str'] = $this->getDataFormatter()->formatBytes($data['memory_usage']);
106+
$data['peak_memory_usage_str'] = $this->getDataFormatter()->formatBytes($data['peak_memory_usage']);
107107

108108
return $data;
109109
}
@@ -126,11 +126,11 @@ protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollecto
126126
'prepared_stmt' => $stmt->getSql(),
127127
'params' => (object) $stmt->getParameters(),
128128
'duration' => $stmt->getDuration(),
129-
'duration_str' => $this->getDataFormater()->formatDuration($stmt->getDuration()),
129+
'duration_str' => $this->getDataFormatter()->formatDuration($stmt->getDuration()),
130130
'memory' => $stmt->getMemoryUsage(),
131-
'memory_str' => $this->getDataFormater()->formatBytes($stmt->getMemoryUsage()),
131+
'memory_str' => $this->getDataFormatter()->formatBytes($stmt->getMemoryUsage()),
132132
'end_memory' => $stmt->getEndMemory(),
133-
'end_memory_str' => $this->getDataFormater()->formatBytes($stmt->getEndMemory()),
133+
'end_memory_str' => $this->getDataFormatter()->formatBytes($stmt->getEndMemory()),
134134
'is_success' => $stmt->isSuccess(),
135135
'error_code' => $stmt->getErrorCode(),
136136
'error_message' => $stmt->getErrorMessage()
@@ -144,11 +144,11 @@ protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollecto
144144
'nb_statements' => count($stmts),
145145
'nb_failed_statements' => count($pdo->getFailedExecutedStatements()),
146146
'accumulated_duration' => $pdo->getAccumulatedStatementsDuration(),
147-
'accumulated_duration_str' => $this->getDataFormater()->formatDuration($pdo->getAccumulatedStatementsDuration()),
147+
'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($pdo->getAccumulatedStatementsDuration()),
148148
'memory_usage' => $pdo->getMemoryUsage(),
149-
'memory_usage_str' => $this->getDataFormater()->formatBytes($pdo->getPeakMemoryUsage()),
149+
'memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()),
150150
'peak_memory_usage' => $pdo->getPeakMemoryUsage(),
151-
'peak_memory_usage_str' => $this->getDataFormater()->formatBytes($pdo->getPeakMemoryUsage()),
151+
'peak_memory_usage_str' => $this->getDataFormatter()->formatBytes($pdo->getPeakMemoryUsage()),
152152
'statements' => $stmts
153153
);
154154
}

src/DebugBar/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function collect()
2525

2626
foreach ($vars as $var) {
2727
if (isset($GLOBALS[$var])) {
28-
$data["$" . $var] = $this->getDataFormater()->formatVar($GLOBALS[$var]);
28+
$data["$" . $var] = $this->getDataFormatter()->formatVar($GLOBALS[$var]);
2929
}
3030
}
3131

src/DebugBar/DataCollector/TimeDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function addMeasure($label, $start, $end)
8787
'end' => $end,
8888
'relative_end' => $end - $this->requestEndTime,
8989
'duration' => $end - $start,
90-
'duration_str' => $this->getDataFormater()->formatDuration($end - $start)
90+
'duration_str' => $this->getDataFormatter()->formatDuration($end - $start)
9191
);
9292
}
9393

@@ -162,7 +162,7 @@ public function collect()
162162
'start' => $this->requestStartTime,
163163
'end' => $this->requestEndTime,
164164
'duration' => $this->getRequestDuration(),
165-
'duration_str' => $this->getDataFormater()->formatDuration($this->getRequestDuration()),
165+
'duration_str' => $this->getDataFormatter()->formatDuration($this->getRequestDuration()),
166166
'measures' => array_values($this->measures)
167167
);
168168
}

src/DebugBar/DataFormater/DataFormater.php renamed to src/DebugBar/DataFormatter/DataFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace DebugBar\DataFormater;
11+
namespace DebugBar\DataFormatter;
1212

13-
class DataFormater implements DataFormaterInterface
13+
class DataFormatter implements DataFormatterInterface
1414
{
1515
public function formatVar($data)
1616
{

src/DebugBar/DataFormater/DataFormaterInterface.php renamed to src/DebugBar/DataFormatter/DataFormatterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace DebugBar\DataFormater;
11+
namespace DebugBar\DataFormatter;
1212

1313
/**
1414
* Formats data to be outputed as string
1515
*/
16-
interface DataFormaterInterface
16+
interface DataFormatterInterface
1717
{
1818
/**
1919
* Transforms a PHP variable to a string representation

tests/DebugBar/Tests/DataFormater/DataFormaterTest.php renamed to tests/DebugBar/Tests/DataFormatter/DataFormatterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
22

3-
namespace DebugBar\Tests\DataFormater;
3+
namespace DebugBar\Tests\DataFormatter;
44

55
use DebugBar\Tests\DebugBarTestCase;
6-
use DebugBar\DataFormater\DataFormater;
6+
use DebugBar\DataFormatter\DataFormatter;
77

8-
class DataFormaterTest extends DebugBarTestCase
8+
class DataFormatterTest extends DebugBarTestCase
99
{
1010
public function testFormatVar()
1111
{
12-
$f = new DataFormater();
12+
$f = new DataFormatter();
1313
$this->assertEquals("bool TRUE", $f->formatVar(true));
1414
}
1515

1616
public function testFormatDuration()
1717
{
18-
$f = new DataFormater();
18+
$f = new DataFormatter();
1919
$this->assertEquals("100μs", $f->formatDuration(0.0001));
2020
$this->assertEquals("100ms", $f->formatDuration(0.1));
2121
$this->assertEquals("1s", $f->formatDuration(1));
@@ -24,7 +24,7 @@ public function testFormatDuration()
2424

2525
public function testFormatBytes()
2626
{
27-
$f = new DataFormater();
27+
$f = new DataFormatter();
2828
$this->assertEquals("0B", $f->formatBytes(0));
2929
$this->assertEquals("1B", $f->formatBytes(1));
3030
$this->assertEquals("1KB", $f->formatBytes(1024));

0 commit comments

Comments
 (0)