filmtools / developing
用于电影开发的PHP类
Requires
- php: ^7.1
- filmtools/commons: ^2.0
- psr/container: ^1.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7|^6.0|^7.0
This package is auto-updated.
Last update: 2024-09-19 22:09:54 UTC
README
用于电影开发的PHP类
安装
$ composer require filmtools/developing
此库需要 filmtools/commons 库以及 psr/container。
Developing类
Developing 类聚集了电影开发所需的所有元素:曝光序列、开发时间和负片密度。
<?php use FilmTools\Developing\Developing; $exposures = array( 0, 0.3, 0.6, 0.9); $densities = array( 0, 0.1, 0.4, 0.6); $dev_time = 600; $developing = new Developing( $exposures, $densities, $dev_time);
构造函数不仅接受曝光和密度数组。它还接受来自 filmtools/commons 库的 Exposures 变体或 Densities 对象
use FilmTools\Commons\Exposures; use FilmTools\Commons\Zones; use FilmTools\Commons\FStops; use FilmTools\Commons\Densities; $exposures = new Exposure 0, 0.3, 0.6, 0.9 ]); $exposures = new Zones([ 0, 1, 2, 3 ]); $exposures = new FStops([ -5, -4, -3, -2 ]); $densities = new Densities([ 0, 0.1, 0.4, 0.6 ]); $developing = new Developing( $exposures, $densities, 600);
方法API
Developing 类实现了 DensitiesProviderInterface,它本身扩展自 ExposuresProviderInterface 和 DensitiesProviderInterface,这两个接口都来自 filmtools/commons 库。
use FilmTools\Commons\Exposures; use FilmTools\Commons\Densities; // Returns "Exposures" instance public function getExposures() : ExposuresInterface; // Returns "Densities" instance public function getDensities() : DensitiesInterface; // Returns the developing time. public function getTime() : int;
DensitiesProviderInterface 还扩展自 \Psr\Container\ContainerInterface、\Countable 和 \IteratorAggregate.
// Countable echo count($developing); // 4
// IteratorAggregate foreach( $developing as $logH => $logD): // noop endforeach;
use Psr\Container\NotFoundExceptionInterface; use FilmTools\Developing\ExposureNotFoundException; // ContainerInterface try { $bool = $developing->has( 99 ); // false $logD = $developing->get( 99 ); // FALSE } catch (NotFoundExceptionInterface $e) { echo get_class($e); // ExposureNotFoundException }
DevelopingFactory
此可调用类从一个关联数组构建一个新的 Developing 实例。构造函数可选地接受扩展自 Developing 的任何类的完全限定名。
class MyClass extends Developing { ... } $developing_factory = new DevelopingFactory; $developing_factory = new DevelopingFactory( MyClass::class ); $developing = $developing_factory([ 'time' => 600, 'exposures' => [ 0, 0.3, 0.6, 0.9 ], 'densities' => [ 0, 0.1, 0.4, 0.6 ], ]);
如果你处理的是曝光值而不是 区域编号 或 f-stops,则传递这些值。它们将被内部转换为曝光值。
$time = 600; $densities = [ 0, 0.1, 0.4, 0.6 ]; $developing = $developing_factory([ 'time' => $time, 'densities' => $densities, 'zones' => [ 0, 1, 2, 3 ], ]); $developing = $developing_factory([ 'time' => $time, 'densities' => $densities, 'fstops' => [ -5, -4, 0, 1, 3 ] ]);
关于字段名称
允许用于 Density 值的字段名称是 logD
、density
和 densities
。
允许用于 Exposure 值的字段名称是 logH
、exposure
和 exposures
。
允许用于 fstops 值的字段名称是 fstop
和 fstops
。
允许用于 区域编号 值的字段名称是 zone
和 zones
。
允许用于 时间 值的字段名称是 seconds
和 time
。
将使用最具体的列。
弃用说明
Developing 类实现了根据 DevelopingInterface 规定的 getData 方法。此方法已弃用,将在下一个主要版本中删除。
开发和单元测试
$ git clone https://github.com/filmtools/developing.git $ cd developing $ composer install # either, or, and: $ composer test $ vendor/bin/phpunit