@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\GeneralName; |
| 6 | 6 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | protected static function _wordsToIPv6String(array $words): string |
| 44 | 44 | { |
| 45 | 45 | $groups = array_map( |
| 46 | - function ($word) { |
|
| 46 | + function($word) { |
|
| 47 | 47 | return sprintf('%04x', $word); |
| 48 | 48 | }, $words); |
| 49 | 49 | return implode(':', $groups); |
@@ -20,15 +20,15 @@ |
||
| 20 | 20 | $mask = null; |
| 21 | 21 | $words = unpack('n*', $octets) ?: []; |
| 22 | 22 | switch (count($words)) { |
| 23 | - case 8: |
|
| 24 | - $ip = self::_wordsToIPv6String($words); |
|
| 25 | - break; |
|
| 26 | - case 16: |
|
| 27 | - $ip = self::_wordsToIPv6String(array_slice($words, 0, 8)); |
|
| 28 | - $mask = self::_wordsToIPv6String(array_slice($words, 8, 8)); |
|
| 29 | - break; |
|
| 30 | - default: |
|
| 31 | - throw new \UnexpectedValueException('Invalid IPv6 octet length.'); |
|
| 23 | + case 8: |
|
| 24 | + $ip = self::_wordsToIPv6String($words); |
|
| 25 | + break; |
|
| 26 | + case 16: |
|
| 27 | + $ip = self::_wordsToIPv6String(array_slice($words, 0, 8)); |
|
| 28 | + $mask = self::_wordsToIPv6String(array_slice($words, 8, 8)); |
|
| 29 | + break; |
|
| 30 | + default: |
|
| 31 | + throw new \UnexpectedValueException('Invalid IPv6 octet length.'); |
|
| 32 | 32 | } |
| 33 | 33 | return new self($ip, $mask); |
| 34 | 34 | } |
@@ -55,15 +55,15 @@ |
||
| 55 | 55 | { |
| 56 | 56 | $octets = $el->asOctetString()->string(); |
| 57 | 57 | switch (strlen($octets)) { |
| 58 | - case 4: |
|
| 59 | - case 8: |
|
| 60 | - return IPv4Address::fromOctets($octets); |
|
| 61 | - case 16: |
|
| 62 | - case 32: |
|
| 63 | - return IPv6Address::fromOctets($octets); |
|
| 64 | - default: |
|
| 65 | - throw new \UnexpectedValueException( |
|
| 66 | - 'Invalid octet length for IP address.'); |
|
| 58 | + case 4: |
|
| 59 | + case 8: |
|
| 60 | + return IPv4Address::fromOctets($octets); |
|
| 61 | + case 16: |
|
| 62 | + case 32: |
|
| 63 | + return IPv6Address::fromOctets($octets); |
|
| 64 | + default: |
|
| 65 | + throw new \UnexpectedValueException( |
|
| 66 | + 'Invalid octet length for IP address.'); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\GeneralName; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\GeneralName; |
| 6 | 6 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'GeneralNames must have at least one GeneralName.'); |
| 52 | 52 | } |
| 53 | 53 | $names = array_map( |
| 54 | - function (UnspecifiedType $el) { |
|
| 54 | + function(UnspecifiedType $el) { |
|
| 55 | 55 | return GeneralName::fromASN1($el->asTagged()); |
| 56 | 56 | }, $seq->elements()); |
| 57 | 57 | return new self(...$names); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | public function allOf(int $tag): array |
| 98 | 98 | { |
| 99 | 99 | $names = array_filter($this->_names, |
| 100 | - function (GeneralName $name) use ($tag) { |
|
| 100 | + function(GeneralName $name) use ($tag) { |
|
| 101 | 101 | return $name->tag() === $tag; |
| 102 | 102 | }); |
| 103 | 103 | return array_values($names); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'GeneralNames must have at least one GeneralName.'); |
| 161 | 161 | } |
| 162 | 162 | $elements = array_map( |
| 163 | - function (GeneralName $name) { |
|
| 163 | + function(GeneralName $name) { |
|
| 164 | 164 | return $name->toASN1(); |
| 165 | 165 | }, $this->_names); |
| 166 | 166 | return new Sequence(...$elements); |
@@ -76,43 +76,43 @@ |
||
| 76 | 76 | { |
| 77 | 77 | switch ($el->tag()) { |
| 78 | 78 | // otherName |
| 79 | - case self::TAG_OTHER_NAME: |
|
| 80 | - return OtherName::fromChosenASN1( |
|
| 81 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 82 | - // rfc822Name |
|
| 83 | - case self::TAG_RFC822_NAME: |
|
| 84 | - return RFC822Name::fromChosenASN1( |
|
| 85 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 86 | - // dNSName |
|
| 87 | - case self::TAG_DNS_NAME: |
|
| 88 | - return DNSName::fromChosenASN1( |
|
| 89 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 90 | - // x400Address |
|
| 91 | - case self::TAG_X400_ADDRESS: |
|
| 92 | - return X400Address::fromChosenASN1( |
|
| 93 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 94 | - // directoryName |
|
| 95 | - case self::TAG_DIRECTORY_NAME: |
|
| 96 | - // because Name is a CHOICE, albeit having only one option, |
|
| 97 | - // explicit tagging must be used |
|
| 98 | - // (see X.680 07/2002 30.6.c) |
|
| 99 | - return DirectoryName::fromChosenASN1($el->asExplicit()); |
|
| 100 | - // ediPartyName |
|
| 101 | - case self::TAG_EDI_PARTY_NAME: |
|
| 102 | - return EDIPartyName::fromChosenASN1( |
|
| 103 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 104 | - // uniformResourceIdentifier |
|
| 105 | - case self::TAG_URI: |
|
| 106 | - return UniformResourceIdentifier::fromChosenASN1( |
|
| 107 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 108 | - // iPAddress |
|
| 109 | - case self::TAG_IP_ADDRESS: |
|
| 110 | - return IPAddress::fromChosenASN1( |
|
| 111 | - $el->asImplicit(Element::TYPE_OCTET_STRING)); |
|
| 112 | - // registeredID |
|
| 113 | - case self::TAG_REGISTERED_ID: |
|
| 114 | - return RegisteredID::fromChosenASN1( |
|
| 115 | - $el->asImplicit(Element::TYPE_OBJECT_IDENTIFIER)); |
|
| 79 | + case self::TAG_OTHER_NAME: |
|
| 80 | + return OtherName::fromChosenASN1( |
|
| 81 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 82 | + // rfc822Name |
|
| 83 | + case self::TAG_RFC822_NAME: |
|
| 84 | + return RFC822Name::fromChosenASN1( |
|
| 85 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 86 | + // dNSName |
|
| 87 | + case self::TAG_DNS_NAME: |
|
| 88 | + return DNSName::fromChosenASN1( |
|
| 89 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 90 | + // x400Address |
|
| 91 | + case self::TAG_X400_ADDRESS: |
|
| 92 | + return X400Address::fromChosenASN1( |
|
| 93 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 94 | + // directoryName |
|
| 95 | + case self::TAG_DIRECTORY_NAME: |
|
| 96 | + // because Name is a CHOICE, albeit having only one option, |
|
| 97 | + // explicit tagging must be used |
|
| 98 | + // (see X.680 07/2002 30.6.c) |
|
| 99 | + return DirectoryName::fromChosenASN1($el->asExplicit()); |
|
| 100 | + // ediPartyName |
|
| 101 | + case self::TAG_EDI_PARTY_NAME: |
|
| 102 | + return EDIPartyName::fromChosenASN1( |
|
| 103 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
| 104 | + // uniformResourceIdentifier |
|
| 105 | + case self::TAG_URI: |
|
| 106 | + return UniformResourceIdentifier::fromChosenASN1( |
|
| 107 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
| 108 | + // iPAddress |
|
| 109 | + case self::TAG_IP_ADDRESS: |
|
| 110 | + return IPAddress::fromChosenASN1( |
|
| 111 | + $el->asImplicit(Element::TYPE_OCTET_STRING)); |
|
| 112 | + // registeredID |
|
| 113 | + case self::TAG_REGISTERED_ID: |
|
| 114 | + return RegisteredID::fromChosenASN1( |
|
| 115 | + $el->asImplicit(Element::TYPE_OBJECT_IDENTIFIER)); |
|
| 116 | 116 | } |
| 117 | 117 | throw new \UnexpectedValueException( |
| 118 | 118 | 'GeneralName type ' . $el->tag() . ' not supported.'); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\GeneralName; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\Certificate; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\Certificate; |
| 6 | 6 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public static function fromASN1(Sequence $seq): Extensions |
| 62 | 62 | { |
| 63 | 63 | $extensions = array_map( |
| 64 | - function (UnspecifiedType $el) { |
|
| 64 | + function(UnspecifiedType $el) { |
|
| 65 | 65 | return Extension::fromASN1($el->asSequence()); |
| 66 | 66 | }, $seq->elements()); |
| 67 | 67 | return new self(...$extensions); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $elements = array_values( |
| 78 | 78 | array_map( |
| 79 | - function ($ext) { |
|
| 79 | + function($ext) { |
|
| 80 | 80 | return $ext->toASN1(); |
| 81 | 81 | }, $this->_extensions)); |
| 82 | 82 | return new Sequence(...$elements); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\Certificate\Extension; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\Certificate\Extension\DistributionPoint; |
| 6 | 6 | |
@@ -40,16 +40,16 @@ |
||
| 40 | 40 | public static function fromTaggedType(TaggedType $el): self |
| 41 | 41 | { |
| 42 | 42 | switch ($el->tag()) { |
| 43 | - case self::TAG_FULL_NAME: |
|
| 44 | - return new FullName( |
|
| 45 | - GeneralNames::fromASN1( |
|
| 46 | - $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 47 | - case self::TAG_RDN: |
|
| 48 | - return new RelativeName( |
|
| 49 | - RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 50 | - default: |
|
| 51 | - throw new \UnexpectedValueException( |
|
| 52 | - 'DistributionPointName tag ' . $el->tag() . ' not supported.'); |
|
| 43 | + case self::TAG_FULL_NAME: |
|
| 44 | + return new FullName( |
|
| 45 | + GeneralNames::fromASN1( |
|
| 46 | + $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 47 | + case self::TAG_RDN: |
|
| 48 | + return new RelativeName( |
|
| 49 | + RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 50 | + default: |
|
| 51 | + throw new \UnexpectedValueException( |
|
| 52 | + 'DistributionPointName tag ' . $el->tag() . ' not supported.'); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Sop\X509\Certificate\Extension\DistributionPoint; |
| 6 | 6 | |