Ejemplo n.º 1
0
 /**
  * @covers BreiteSeite\IP\IPv6\Address::createIPv4Mapped()
  * @covers BreiteSeite\IP\IPv6\Address::getAsBinary()
  */
 public function testCreateIpv4Mapped()
 {
     $address = Address::createIPv4Mapped(\BreiteSeite\IP\IPv4\Address::fromString('0.0.0.1'));
     $this->assertSame('00000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111100000000000000000000000000000001', $address->getAsBinary());
 }
Ejemplo n.º 2
0
 /**
  * @param string $ip
  * @param int $integer
  *
  * @dataProvider getIpAddressAsStringAndInteger
  * @covers \BreiteSeite\IP\IPv4\Address::getAsInteger()
  */
 public function testFromString(string $ip, int $integer, string $binary)
 {
     $ip = Address::fromString($ip);
     $this->assertSame($integer, $ip->getAsInteger());
     $this->assertSame($binary, $ip->getAsBinary());
 }
Ejemplo n.º 3
0
 public static function createIPv4Mapped(\BreiteSeite\IP\IPv4\Address $ipv4Address) : self
 {
     $mappedIpBinaryString = str_repeat('0', 80) . str_repeat('1', 16) . $ipv4Address->getAsBinary();
     return new self(gmp_init($mappedIpBinaryString, 2));
 }