1<?php 2/** 3 * This file is part of the FreeDSx ASN1 package. 4 * 5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11namespace FreeDSx\Asn1\Type; 12 13/** 14 * Represents the various ASN1 string types. 15 * 16 * @author Chad Sikorra <Chad.Sikorra@gmail.com> 17 */ 18abstract class AbstractStringType extends AbstractType 19{ 20 /** 21 * @var bool 22 */ 23 protected $isCharRestricted = false; 24 25 public function __construct($value = '') 26 { 27 parent::__construct($value); 28 } 29 30 /** 31 * @return string 32 */ 33 public function getValue() 34 { 35 return $this->value; 36 } 37 38 /** 39 * @param string $value 40 * @return $this 41 */ 42 public function setValue($value) 43 { 44 $this->value = $value; 45 46 return $this; 47 } 48 49 /** 50 * @return string 51 */ 52 public function __toString() 53 { 54 return (string) $this->value; 55 } 56 57 /** 58 * @return bool 59 */ 60 public function isCharacterRestricted() 61 { 62 return $this->isCharRestricted; 63 } 64 65 /** 66 * @param string|int $tagNumber 67 * @param int $class 68 * @param bool $isConstructed 69 * @param string $value 70 * @return AbstractStringType 71 */ 72 public static function withTag($tagNumber, int $class, bool $isConstructed, $value = '') 73 { 74 $type = new static($value); 75 $type->taggingClass = $class; 76 $type->tagNumber = $tagNumber; 77 $type->isConstructed = $isConstructed; 78 79 return $type; 80 } 81} 82