Protobuf\Field::getLabelName PHP Method

getLabelName() public static method

Obtain the label name (repeated, optional, required).
public static getLabelName ( string $label ) : string
$label string
return string
    public static function getLabelName($label)
    {
        if ($label === self::LABEL_OPTIONAL) {
            return 'optional';
        }
        if ($label === self::LABEL_REQUIRED) {
            return 'required';
        }
        if ($label === self::LABEL_REPEATED) {
            return 'repeated';
        }
        return null;
    }

Usage Example

 /**
  * Obtain the rule for the given field (repeated, optional, required).
  *
  * @param \google\protobuf\FieldDescriptorProto $field
  *
  * @return string
  */
 protected function getFieldLabelName(FieldDescriptorProto $field)
 {
     $label = $field->getLabel()->value();
     $name = Field::getLabelName($label);
     return $name ?: 'unknown';
 }
All Usage Examples Of Protobuf\Field::getLabelName