AloWAMP source documentation
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • None
  • PHP
  • Setup
  • VersionSwitch

Classes

  • cURL
  • Downloader
  • Format
  • Handler
  • IO
  • Router
  • Service
  • Settings
  • Setup

Functions

  • _echo
  • get
 1 <?php
 2 
 3    /**
 4     * Formats stuff
 5     *
 6     * @author Art <a.molcanovas@gmail.com>
 7     */
 8    abstract class Format {
 9 
10       /**
11        * Removes "." and ".." entries from scandir()
12        *
13        * @author Art <a.molcanovas@gmail.com>
14        *
15        * @param array $scandir Reference to scandir() results
16        */
17       static function formatScandir(&$scandir) {
18          $scandir = array_filter($scandir,
19             function ($r) {
20                return $r != '.' && $r != '..';
21             });
22 
23          $r = [];
24 
25          foreach($scandir as $d) {
26             $r[] = $d;
27          }
28 
29          $scandir = $r;
30       }
31 
32       /**
33        * Returns a human-friendly filesize
34        *
35        * @param int $bytes Filesize in bytes
36        *
37        * @author Art <a.molcanovas@gmail.com>
38        * @return string
39        */
40       static function filesize($bytes) {
41          if(!is_numeric($bytes) || $bytes < 1024) {
42             return $bytes . ' B';
43          } elseif($bytes < 1048576) {
44             return round($bytes / 1024, 3) . ' KB';
45          } elseif($bytes < 1073741824) {
46             return round($bytes / 1048576, 3) . ' MB';
47          } else {
48             return round($bytes / 1073741824, 3) . ' GB';
49          }
50       }
51 
52       /**
53        * Turns an ini to an array.
54        *
55        * @param string $var     Ini contents or filepath
56        * @param bool   $is_file TRUE if $var is a filepath, FALSE if ini contents
57        *
58        * @return array
59        */
60       static function ini_to_array($var, $is_file = true) {
61          return $is_file ? parse_ini_file($var, true) : parse_ini_string($var, true);
62       }
63    }
AloWAMP source documentation API documentation generated byApiGen 2.8.0