florianwolters/component-core-cloneable
Composer 安装命令:
composer require florianwolters/component-core-cloneable
包简介
Allows and disallows the cloning of objects as a PHP component.
README 文档
README
FlorianWolters\Component\Core\Cloneable is a simple-to-use PHP component that allows and disallows the cloning of objects.
Table of Contents (ToC)
- Introduction
- Features
- Requirements
- Usage
- Installation
- As A Dependency On Your Component
- Contributing
- Credits
- License
Introduction
This component is inspired by the the Java programming language.
FlorianWolters\Component\Core\Cloneable consists of six artifacts:
- The interface
FlorianWolters\Component\Core\CloneableInterface: Indicates to the magic__clonemethod of a class that it is legal for that method to make a field-for-field copy of instances of that class. - The exception class
FlorianWolters\Component\Core\CloneNotSupportedException: Indicates that the magic__clonemethod in a class has been called to clone an object, but that the object's class does not implement theCloneableInterface. - The trait
FlorianWolters\Component\Core\CloneNotSupportedTrait: Indicates to the magic__clonemethod of a class that it is illegal for that method to make a field-for-field copy of instances of that class. - The trait
FlorianWolters\Component\Core\ShallowCloneTrait: Indicates to the magic__clonemethod of a class that it is legal for that method to make a shallow field-for-field copy of instances of that class. - The trait
FlorianWolters\Component\Core\DeepCloneTrait: Indicates to the magic__clonemethod of a class that it is legal for that method to make a deep field-for-field copy of instances of that class. - The static class
FlorianWolters\Component\Core\CloneUtils: Offers operations to clone objects.
Features
- Disallows cloning via the magic method
__cloneby using the traitCloneNotSupportedTrait. When trying to copy an object via theclonekeyword, aCloneNotSupportedExceptionis thrown. - Allows (type safe) cloning via the magic method
__cloneby implementing the interfaceCloneableInterfaceand using one of the two traitsShallowCloneTraitto make a shallow orDeepCloneTraitto make a deep copy of an instance of the class. - Allows creating deep copies of any object via the method
copyDeepof the classCloneUtils. - Artifacts tested with both static and dynamic test procedures:
- Dynamic component tests (unit and integration tests) implemented with PHPUnit.
- Static code analysis performed using the following tools:
- PHP_CodeSniffer: Style Checker
- PHP Mess Detector (PHPMD): Code Analyzer
- PHP Depend: Code Metrics
- phpcpd: Copy/Paste Detector (CPD)
- phpdcd: Dead Code Detector (DCD)
- SensioLabs Security Checker: Security Checker
- Continuous Integration (CI) using the following web services:
- Provides a Packagist package which can be installed using the dependency manager Composer. Click here for the package on Packagist.
- Provides a complete Application Programming Interface (API) documentation generated with the documentation generator phpDocumentor. Click here for the API documentation.
- Follows the following "standards" from the PHP Framework Interoperability Group (FIG). PSR stands for PHP Standards Recommendation:
-
PSR-0: Autoloading Standards
Aims to provide a standard file, class and namespace convention to allow plug-and-play code.
-
PSR-1: Basic Coding Standard
Aims to ensure a high level of technical interoperability between shared PHP code.
-
PSR-2: Coding Style Guide
Provides a Coding Style Guide for projects looking to standardize their code.
-
PSR-4: Autoloader
A more modern take on autoloading reflecting advances in the ecosystem.
-
- Follows the Semantic Versioning (SemVer) specification version 2.0.0.
Requirements
Production
Development
- PHPUnit
- phpcpd
- phpdcd
- PHP_CodeSniffer
- PHP Mess Detector (PHPMD)
- PDepend
- phpDocumentor
- SensioLabs Security Checker
- php-coveralls
Usage
The best documentation for FlorianWolters\Component\Core\Cloneable are the unit tests, which are shipped in the package.
Installation
FlorianWolters\Component\Core\Cloneable should be installed using the dependency manager Composer.
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
The Composer installer can be downloaded with php.
php -r "readfile('https://getcomposer.org/installer');" | php
This will just check a few PHP settings and then download
composer.pharto your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
To resolve and download dependencies, run the
installcommand:
php composer.phar install
As A Dependency On Your Component
If you are creating a component that relies on FlorianWolters\Component\Core\Cloneable, please make sure that you add FlorianWolters\Component\Core\Cloneable to your component's composer.json file:
{
"require": {
"florianwolters/component-core-cloneable": "0.3.*"
}
}
Contributing
See CONTRIBUTING.md.
Credits
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://gnu.org/licenses/lgpl.txt.
florianwolters/component-core-cloneable 适用场景与选型建议
florianwolters/component-core-cloneable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 719 次下载、GitHub Stars 达 3, 最近一次更新时间为 2013 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「creation」 「cloning」 「clone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 florianwolters/component-core-cloneable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 florianwolters/component-core-cloneable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 florianwolters/component-core-cloneable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Singleton (and Registry of Singletons a.k.a. Multiton) design pattern as a PHP component.
Traits gathering fluent syntax common methods
PHP class that creates animated GIF from multiple images
A fork of the great myclabs/DeepCopy bundle for Symfony
Collection of tools to use the full power of the Enyalius framework
Renderforest SDK for PHP
统计信息
- 总下载量: 719
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 23
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2013-02-21