rm/unique 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rm/unique

最新稳定版本:v0.1.0

Composer 安装命令:

composer require rm/unique

包简介

Library for generating unique file names.

README 文档

README

Build Status Code Quality Code Coverage Packagist

Uniqe is simple library for generating unique filenames in directories.

Requirements

Unique requires PHP 5.4 or later.

Installation

The best way to install Unique is use Composer package rm/unique or manual download the latest ZIP package from GitHub.

$ composer require rm/unique

Example

I need upload file something.png into directory /images.

If it is necessary to not overwrite existing files, you need to generate unique filenames.

Now it's simple!

$filename = Unique::get('something.png', '/images'); // return 'something.png'

And what if directory contains files something.png and for example, also something-1.png?

Returns something-2.png!

Unique::get() automatic generate filename in format <filename><separator><order>.<extension> and check if exists in specified directory. If is unique, return it.

API

get()

Method get() has two parameters:

  • string $filename Name of file
  • string $dir Directory where will be file saved

Return

  • string Output filename

$separator

Default separator of filename and order it's -. It's possible change it, for example:

Unique::$separator = '|';

Contributing

  • Use it!
  • Write bug reports of ideas into Issue tracker.
  • Fork repos and send pull requests with number of issue, source code and tests.

Contact

Roman Mátyus romanmatyus@romiix.org

统计信息

  • 总下载量: 196
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-26