ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
MemoryProcessor.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Processor;
13
19abstract class MemoryProcessor
20{
24 protected $realUsage;
25
29 protected $useFormatting;
30
35 public function __construct($realUsage = true, $useFormatting = true)
36 {
37 $this->realUsage = (boolean) $realUsage;
38 $this->useFormatting = (boolean) $useFormatting;
39 }
40
47 protected function formatBytes($bytes)
48 {
49 $bytes = (int) $bytes;
50
51 if (!$this->useFormatting) {
52 return $bytes;
53 }
54
55 if ($bytes > 1024*1024) {
56 return round($bytes/1024/1024, 2).' MB';
57 } elseif ($bytes > 1024) {
58 return round($bytes/1024, 2).' KB';
59 }
60
61 return $bytes . ' B';
62 }
63}
Some methods that are common for all memory processors.
__construct($realUsage=true, $useFormatting=true)
formatBytes($bytes)
Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes a...