/** * @covers ::remove * @dataProvider removeBits */ public function testRemoveBit(Bitmask $mask, $bit, $already_has, $positive_bit) { $this->assertTrue($mask->has($positive_bit), 'Mask should have positive bit before other is removed'); $this->assertSame($already_has, $mask->has($bit)); $this->assertSame($mask, $mask->remove($bit), 'Bitmask::removeshould be chainable'); $this->assertFalse($mask->has($bit), 'Mask should not have bit after it is removed'); $this->assertTrue($mask->has($positive_bit), 'Mask should still have positive bit after other is removed'); }
/** * @expectedException Exception */ public function testRemoveInvalidThrow() { Bitmask::remove(42, 1); }
public function __construct(Uri $uri_) { $this->m_uri = $uri_; $this->m_options = Bitmask::createEmpty(); }
public static function containsValueBySubstring(array $array_, $substring_, $mode_ = 3, array &$parentKeys_ = []) { $exists = false; $nestedArrays = []; $recursive = Bitmask::hasBitForBitmask($mode_, self::RECURSIVE); // search current level foreach ($array_ as $key => $value) { if (is_array($value)) { $nestedArrays[] = $key; } else { if (false === $exists) { $exists = String::contains($value, $substring_); if (false !== $exists) { $exists = $key; if (false === $recursive) { return $exists; } } } } } if (false === $recursive) { return $exists; } // proceed with nested levels if requested foreach ($nestedArrays as $nestedArray) { $exists = self::containsValueBySubstring($array_[$nestedArray], $substring_, $mode_, $parentKeys_); if (false !== $exists) { array_unshift($parentKeys_, $nestedArray); return $exists; } } return $exists; }
<?php namespace Components; Annotations::registerAnnotations([Annotation_Cache::NAME => Annotation_Cache::TYPE, Annotation_Collection::NAME => Annotation_Collection::TYPE, Annotation_Id::NAME => Annotation_Id::TYPE, Annotation_Transient::NAME => Annotation_Transient::TYPE]); Resource_Type::registerResourceType('mysql', Persistence_Resource_Pdo_Mysql::type()); Resource_Type::registerResourceType('mongodb', Persistence_Resource_Mongodb::type()); Persistence_Resource_Schema::serve('schema'); Persistence::registerResource('nosql', ['mongodb://127.0.0.1/' . COMPONENTS_INSTANCE_CODE]); Debug::addFlagListener(function ($active_, array $flags_) { if ($active_) { $bits = []; if (isset($flags_[Persistence::LOG_STATEMENTS])) { $bits[] = Persistence::BIT_LOG_STATEMENTS; } if (isset($flags_[Persistence::LOG_QUERIES])) { $bits[] = Persistence::BIT_LOG_QUERIES; } if (isset($flags_[Persistence::PROFILE])) { $bits[] = Persistence::BIT_PROFILE; } Persistence::$debugMode = Bitmask::getBitmaskForBits($bits); } else { Persistence::$debugMode = Persistence::BIT_NO_DEBUG; } });
/** * @expectedException \PhpBinaryReader\Exception\InvalidDataException */ public function testExceptionIsThrownIfMaskTypeIsUnsupported() { $bitmask = new Bitmask(); $bitmask->getMask(5, 5); }
/** * @see \Components\Cloneable::__clone() __clone */ public function __clone() { $url = new self(); $url->m_scheme = $this->m_scheme; $url->m_host = $this->m_host; $url->m_port = $this->m_port; $url->m_username = $this->m_username; $url->m_password = $this->m_password; // clone arrays? $url->setPathParams($this->getPathParams()); $url->setQueryParams($this->getQueryParams()); $url->m_fragment = $this->m_fragment; if (null !== $this->m_options) { $url->m_options = Bitmask::forBitmask($this->m_options->toBitmask()); } return $url; }