tmilos / scim-schema
SCIM schema 库
0.1
2017-11-25 22:18 UTC
Requires (Dev)
- phpunit/phpunit: ^4.8|^5.6
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2024-09-14 20:35:38 UTC
README
支持 v1 和 v2 的 SCIM schema PHP 库。
注意: 此库仍在开发中,欢迎您提供帮助和贡献
它是由 SimpleCloud 规范 SimpleCloud 和由 PowerDMS/Owin.Scim 生成的示例文档 PowerDMS/Owin.Scim 制作的
不要错过 SCIM Filter Parser !
安装
使用 composer 安装 Scim Schema
composer require tmilos/scim-schema
用法
架构
构建默认架构
$schemaBuilder = new SchemaBuilderV2(); // or SchemaBuilderV1 $groupSchema = $schemaBuilder->getGroup(); $userSchema = $schemaBuilder->getUser(); $enterpriseUserSchema = $schemaBuilder->getEnterpriseUser(); $schemaSchema = $schemaBuilder->getSchema(); $serviceProviderConfigSchema = $schemaBuilder->getServiceProviderConfig(); $resourceTypeSchema = $schemaBuilder->getResourceType();
或构建自定义架构
$schema = new Schema(); $schema->setName('CustomSchema'); $schema->addAttribute( AttributeBuilder::create('name', ScimConstants::ATTRIBUTE_TYPE_STRING, 'Name of the object') ->setMutability(false) ->getAttribute() );
并序列化 SCIM 架构对象
$schema = (new SchemaBuilderV2())->getUser(); $schema->serializeObject();
架构验证
对象可以与架构进行验证
/** @var array $object */ $object = getTheObjectAsArray(); $validator = new SchemaValidator(); $objectSchema = getTheSchema(); $schemaExtensions = getSchemaExtensions(); $validationResult = $validator->validate( $object, $objectSchema, $schemaExtensions ); if (!$validationResult->getErrors()) { // cool! } else { print implode("\n", $validationResult->getErrorsAsStrings()); }