Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
 1 <?php
 2 /**
 3  * Util.php
 4  *
 5  * @author  Elvyrra SAA
 6  * @license http://rem.mit-license.org/ MIT
 7  */
 8 
 9 namespace Hawk;
10 
11 /**
12  * This trait contains utilities method that cen be used anywhere in the core
13  *
14  * @package Utils
15  */
16 trait Utils{
17     /**
18      * Display variables for development debug
19      *
20      * @param mixed $var  The variable to display
21      * @param bool  $exit if set to true, exit the script
22      */
23     public static function debug($var, $exit = false){
24         if(DEBUG_MODE) {
25             $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
26             echo "<pre>" ,
27                     var_export($var, true) , PHP_EOL ,
28                     $trace['file'], ":", $trace['line'], PHP_EOL,
29                 "</pre>";
30 
31             if($exit) {
32                 exit;
33             }
34         }
35     }
36 
37 
38     /**
39      * Serialize a version number as integer.
40      * Example :
41      * <code>
42      * <?php
43      *      echo Utils::getSerializedVersion('1.15.12'); // Output "01151200"
44      * ?>
45      * </code>
46      *
47      * @param string $version The version number to serialize, in the format gg.rr.cc(.pp)
48      *
49      * @return string The serialized version
50      */
51     public static function getSerializedVersion($version){
52         $digits = explode('.', $version);
53         $number = '';
54         foreach(range(0, 3) as $i) {
55             if(empty($digits[$i])) {
56                 $digits[$i] = '00';
57             }
58             $number .= str_pad($digits[$i], 2, '0', STR_PAD_LEFT);
59         }
60         return $number;
61     }
62 
63     /**
64      * Map an array data to the object that use this trait
65      *
66      * @param array  $array  The data to map to the object
67      * @param Object $object The object to map. If not set, get $this in the execution context of the method
68      */
69     public function map($array, $object = null){
70         if($object === null) {
71             $object = $this;
72         }
73         foreach($array as $key => $value){
74             $object->$key = $value;
75         }
76     }
77 }
Hawk - PHP documentation API documentation generated by ApiGen