2017 © Pedro Peláez
 

library toolkit-fileinfo

File information component

image

gmi/toolkit-fileinfo

File information component

  • Monday, May 28, 2018
  • by gmi
  • Repository
  • 2 Watchers
  • 1 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

PHP Toolkit - Fileinfo

This library provides features to read file information., (*1)

It provides an abstraction layer above SplFileInfo for consistent behavior and easier usage. * Ability to retrieve the file name without its extension * Human-readable file sizes * Usage of DateTime objects instead of Unix timestamps * Ability to retrieve the file owner/group (via posix_* functions) * Human-readable permissions, (*2)

File information is read during construction of the FileInfo instance or when FileInfo::reload() is called., (*3)

For easier dependency injection in projects, a simple FileInfoFactory is provided., (*4)

The current build status and code analysis can be found here: * Scrutinizer CI, (*5)

Requirements

  • PHP 5.6.0 or higher
  • PHP mbstring extension
  • PHP posix extension

Installation

The recommended way to install toolkit-fileinfo is via composer., (*6)

"require": {
    "gmi/toolkit-fileinfo": "1.1.*"
}

Usage examples

use Gmi\Toolkit\Fileinfo\FileInfo;

$fileInfo = new FileInfo('/path/to/awesome.pdf');

/**
 * Get information about file path:
 * @see Gmi\Toolkit\Fileinfo\Part\PathInfo
 */

$fileInfo->path()->getPath();
// '/path/to'

$fileInfo->path()->getFilename();
// 'awesome.pdf'

$fileInfo->path()->getFilenameWithoutExtension();
// 'awesome'

$fileInfo->path()->getExtension();
// 'pdf'

/**
 * Get information about file size:
 * @see Gmi\Toolkit\Fileinfo\Part\SizeInfo
 */

$fileInfo->size()->getSize();
// 34703

$fileInfo->size()->getSizeFormatted();
// '33.89 KiB'

/**
 * Get information about file dates:
 * @see Gmi\Toolkit\Fileinfo\Part\DateInfo
 */

$fileInfo->date()->getLastAccessed();
// object(DateTime)

$fileInfo->date()->getLastModified();
// object(DateTime)

/**
 * Get information about file permissions:
 * @see Gmi\Toolkit\Fileinfo\Part\PermissionInfo
 */

$fileInfo->perm()->getOwner();
// 0

$fileInfo->perm()->getOwnerName();
// 'root'

$fileInfo->perm()->getPermsFormatted();
// 'rw-r--r--'

/**
 * Get information about file type:
 * @see Gmi\Toolkit\Fileinfo\Part\TypeInfo
 */

$fileInfo->type()->getMimeType();
// 'application/pdf'

/**
 * Reload file information:
 */
$fileInfo->reload();

Tests

The test suite can be run with vendor/bin/phpunit tests. Tests are insulated by using a temporary directory per test., (*7)

The Versions

28/05 2018

dev-master

9999999-dev https://github.com/gmitirol/toolkit-fileinfo

File information component

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.6.0
  • ext-mbstring *
  • ext-posix *

 

The Development Requires

by Andreas Erhard

28/05 2018

1.1.1

1.1.1.0 https://github.com/gmitirol/toolkit-fileinfo

File information component

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.6.0
  • ext-mbstring *
  • ext-posix *

 

The Development Requires

by Andreas Erhard

19/02 2018

1.1.0

1.1.0.0 https://github.com/gmitirol/toolkit-fileinfo

File information component

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.6.0
  • ext-mbstring *
  • ext-posix *

 

The Development Requires

by Andreas Erhard

07/02 2018

1.0.1

1.0.1.0 https://github.com/gmitirol/toolkit-fileinfo

File information component

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.6.0
  • ext-mbstring *
  • ext-posix *

 

The Development Requires

by Andreas Erhard

07/02 2018

1.0.0

1.0.0.0 https://github.com/gmitirol/toolkit-fileinfo

File information component

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.6.0
  • ext-mbstring *
  • ext-posix *

 

The Development Requires

by Andreas Erhard