You are here

class Kint_Objects_SplFileInfo in Devel 8

Same name and namespace in other branches
  1. 8.2 kint/kint/parsers/objects/splfileinfo.php \Kint_Objects_SplFileInfo

Hierarchy

Expanded class hierarchy of Kint_Objects_SplFileInfo

File

kint/kint/parsers/objects/splfileinfo.php, line 3

View source
class Kint_Objects_SplFileInfo extends KintObject {
  public function parse(&$variable) {
    if (!KINT_PHP53 || !is_object($variable) || !$variable instanceof SplFileInfo) {
      return false;
    }
    $this->name = 'SplFileInfo';
    $this->value = $variable
      ->getBasename();
    $flags = array();
    $perms = $variable
      ->getPerms();
    if (($perms & 0xc000) === 0xc000) {
      $type = 'File socket';
      $flags[] = 's';
    }
    elseif (($perms & 0xa000) === 0xa000) {
      $type = 'File symlink';
      $flags[] = 'l';
    }
    elseif (($perms & 0x8000) === 0x8000) {
      $type = 'File';
      $flags[] = '-';
    }
    elseif (($perms & 0x6000) === 0x6000) {
      $type = 'Block special file';
      $flags[] = 'b';
    }
    elseif (($perms & 0x4000) === 0x4000) {
      $type = 'Directory';
      $flags[] = 'd';
    }
    elseif (($perms & 0x2000) === 0x2000) {
      $type = 'Character special file';
      $flags[] = 'c';
    }
    elseif (($perms & 0x1000) === 0x1000) {
      $type = 'FIFO pipe file';
      $flags[] = 'p';
    }
    else {
      $type = 'Unknown file';
      $flags[] = 'u';
    }

    // owner
    $flags[] = $perms & 0x100 ? 'r' : '-';
    $flags[] = $perms & 0x80 ? 'w' : '-';
    $flags[] = $perms & 0x40 ? $perms & 0x800 ? 's' : 'x' : ($perms & 0x800 ? 'S' : '-');

    // group
    $flags[] = $perms & 0x20 ? 'r' : '-';
    $flags[] = $perms & 0x10 ? 'w' : '-';
    $flags[] = $perms & 0x8 ? $perms & 0x400 ? 's' : 'x' : ($perms & 0x400 ? 'S' : '-');

    // world
    $flags[] = $perms & 0x4 ? 'r' : '-';
    $flags[] = $perms & 0x2 ? 'w' : '-';
    $flags[] = $perms & 0x1 ? $perms & 0x200 ? 't' : 'x' : ($perms & 0x200 ? 'T' : '-');
    $size = sprintf('%.2fK', $variable
      ->getSize() / 1024);
    $flags = implode($flags);
    $path = $variable
      ->getRealPath();
    return array(
      'File information' => array(
        'Full path' => $path,
        'Type' => $type,
        'Size' => $size,
        'Flags' => $flags,
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
KintObject::$name public property @var string type of variable, can be set in inherited object or in static::parse() method
KintObject::$value public property @var string quick variable value displayed inline
Kint_Objects_SplFileInfo::parse public function * returns false or associative array - each key represents a tab in default view, values may be anything * * Overrides KintObject::parse