tourze/gb-t-4658

GB/T 4658 学历代码

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/tourze/gb-t-4658

0.0.3 2025-05-29 10:23 UTC

This package is auto-updated.

Last update: 2025-11-01 19:16:42 UTC


README

English | 中文

Latest Version Build Status Quality Score Total Downloads

A PHP 8.1+ enum implementation of GB/T 4658-2006 Codes for Record of Formal Schooling standard. This package provides a complete mapping of Chinese education system formal schooling codes, suitable for education institutions, HR management, information processing, and data exchange scenarios.

Features

  • Complete standard compliance: Full implementation of GB/T 4658-2006 standard
  • Type-safe: Built with PHP 8.1+ enums for type safety
  • Rich functionality: Provides labels, item arrays, and select options
  • Educational coverage: Covers all levels from primary school to postgraduate education
  • Easy integration: Simple API design for seamless integration
  • Extensible: Supports custom labels and options through trait implementation

Installation

Requirements

  • PHP 8.1 or higher
  • tourze/enum-extra package

Install via Composer

composer require tourze/gb-t-4658

Quick Start

<?php

use Tourze\GBT4658\FormalSchooling;

// Get Chinese label
echo FormalSchooling::UNDERGRADUATE_GRADUATE->getLabel(); // "大学本科毕业"

// Get code value
echo FormalSchooling::UNDERGRADUATE_GRADUATE->value; // "21"

// Get all items as array
$items = FormalSchooling::items(); // Returns array of all items with labels

// Get select options for forms
$options = FormalSchooling::select(); // Returns array of options for select elements

// Convert to array
$array = FormalSchooling::MASTERS_GRADUATE->toArray();
// Result: ['value' => '14', 'label' => '硕士研究生毕业']

// Parse from code value
$schooling = FormalSchooling::from('21'); // Returns UNDERGRADUATE_GRADUATE
$schooling = FormalSchooling::tryFrom('99'); // Returns null for invalid codes

Available Codes

The package includes all codes defined in GB/T 4658-2006:

  • Postgraduate Education (10-19): Doctoral, Masters, Graduate class
  • Undergraduate Education (20-28): University undergraduate levels
  • College Education (30-39): College/Associate degree levels
  • Secondary Vocational Education (40-49): Technical schools, vocational high schools
  • High School Education (60-69): General high school levels
  • Middle School Education (70-79): Junior high school levels
  • Primary Education (80-89): Primary school levels
  • Other (90): Other educational backgrounds

API Reference

Methods

  • getLabel(): Get Chinese label for the schooling level
  • toArray(): Convert to array with value and label
  • toSelectItem(): Convert to select item with additional fields
  • from(string $value): Parse enum from code value (throws exception if invalid)
  • tryFrom(string $value): Parse enum from code value (returns null if invalid)

Static Methods

  • items(): Get all items as array
  • select(): Get all items as select options
  • genOptions(): Generate options for form elements
  • cases(): Get all enum cases

Contributing

We welcome contributions! Please follow these guidelines:

  • Fork the repository and create a feature branch
  • Follow PSR-12 code style standards
  • Write comprehensive tests for new features
  • Ensure all tests pass before submitting a pull request
  • Update documentation as needed

License

This package is licensed under the MIT License. See the LICENSE file for details.

Changelog

For information about recent changes, see the CHANGELOG file.

Support