/** * @param string $scope The locking mechanism to use ({@link Lock::EXCLUSIVE} or {@link Lock::SHARED} lock) * @param string $type The lock type (At present, write lock is the only supported type of locking) * * @throws \InvalidArgumentException When the locking mechanism or lock type specified is not supported */ public function __construct($scope = 'exclusive', $type = 'write') { if ($scope != Lock::EXCLUSIVE && $scope != Lock::SHARED) { throw new \InvalidArgumentException('The locking mechanism specified is not supported'); } if ($type != 'write') { throw new \InvalidArgumentException('The lock type specified is not supported'); } $this->type = $type; $this->scope = $scope; $this->timeout = TimeoutHeader::getInfinite(); $this->depth = 0; }
public function testSetTimeoutAsObject() { $this->lock->setTimeout(TimeoutHeader::getInfinite()); $this->assertEquals(TimeoutHeader::INFINITE, $this->lock->getTimeout()); }