Add a discriminator to a class.

@param string $class              The Class
@param string $key                Key is the database value and values are the classes
@param string $discriminatorClass The mapped class
508472
public function addDiscriminator($class, $key, $discriminatorClass)
    {
        if (!isset($this->discriminators[$class])) {
            $this->discriminators[$class] = [];
        }

        if (!isset($this->discriminators[$class][$key])) {
            $this->discriminators[$class][$key] = $discriminatorClass;
        }
    }
1249933
public function addClass(&$class)
    {
        if (isset($this->_classes[$class->name()])) {
            $phpdoctor =& $this->_root->phpdoctor();
            echo "\n";
            $phpdoctor->warning('Found class '.$class->name().' again, overwriting previous version');
        }
        $this->_classes[$class->name()] =& $class;
    }
1003685
protected function addClass(string $class)
    {
        if ($this->initialized) {
            throw new RuntimeException("You can't register provider class as registry as been initialized.");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Class $class does not exist.");
        }

        if (!is_subclass_of($class, ProviderInterface::class)) {
            throw new InvalidArgumentException("Class $class must implement " . ProviderInterface::class);
        }

        $this->classes[] = $class;
    }
1137156
public function Identify($name, $class)
    {
        $method = 'make'.lcfirst($name);
        if(method_exists($this, $method))
            $this->{$name}($class);
    }
142665
private function setShardKey(ClassMetadataInfo $class, ODM\ShardKey $shardKey)
    {
        $options = array();
        $allowed = array('unique', 'numInitialChunks');
        foreach ($allowed as $name) {
            if (isset($shardKey->$name)) {
                $options[$name] = $shardKey->$name;
            }
        }

        $class->setShardKey($shardKey->keys, $options);
    }
183295
public function setLoggerClass($class)
  {
    $prev = $this->configuration['logger_class'];
    if (!isset($this->configuration['classes'][$class]) &&
        isset($this->configuration['classes'][$prev])) {
      $this->configuration['classes'][$class] =
          $this->configuration['classes'][$prev];
    }
    $this->configuration['logger_class'] = $class;
  }
560992
protected function defineEntity(ClassDefinition $class)
    {
        $class->property($this->name)->asString();

        $class->property($this->slug)->asString();

        $class->property($this->role)->asString();

        $class->property($this->bio)->asObject(Html::class);

        $class->property($this->articles)->asType(BlogArticle::collectionType());

        $this->defineMetadata($class);
    }
1040935
public void addClass (ClassRecord record)
    {
        // validate the class id
        if (record.classId > 255) {
            log.warning("Refusing to add class; classId > 255 " + record + ".");
        } else {
            _classes.put(record.classId, record);
        }
    }
84519
public function remove_class($class) {
        if (in_array($class, $this->classes)) {
            $key = array_search($class,$this->classes);
            if ($key!==false) {
                unset($this->classes[$key]);
                return true;
            }
        }
        return false;
    }
952511
protected function defineEntity(ClassDefinition $class)
    {
        $class->property($this->email)->asObject(EmailAddress::class);
        
        $class->property($this->name)->asString();

        $class->property($this->subject)->asString();

        $class->property($this->message)->asString();

        $class->property($this->createdAt)->asObject(DateTime::class);
    }
467135
public function removeClass(?string $class): void
  {
    // If class is empty or no classes are set return immediately.
    if ($class===null || $class==='' || !isset($this->attributes['class'])) return;

    // Remove the class from the list of classes.
    $this->attributes['class'] = implode(' ', array_diff(explode(' ', $this->attributes['class']), [$class]));
  }
1237966
public function loadClassMetadata(LoadClassMetadataEventArgs $class)
    {
        $metaData = $class->getClassMetadata();
        $adoptees = $this->collector->getAdoptees($metaData->name);
        foreach ($adoptees as $discriminator => $adoptee) {
            $metaData->discriminatorMap[$discriminator] = $adoptee;
        }
    }
1132250
private void buildDiscriminatorNodes(DiscriminatorNode node) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "buildDiscriminatorNodes: " + node);
        }
        DiscriminatorNode dn = node;
        if (dn == null) {
            return;
        }
        DiscriminatorNode newDN = null, lastDN = null;
        discriminators = new DiscriminatorNode(dn.disc, dn.weight, null, null);
        discAL.add(dn.disc);
        Channel chan = dn.disc.getChannel();
        addChannel(chan);
        newDN = discriminators;
        lastDN = discriminators;
        while (dn.next != null) {
            dn = dn.next;
            newDN = new DiscriminatorNode(dn.disc, dn.weight, null, lastDN);
            lastDN.next = newDN;
            lastDN = newDN;
            discAL.add(dn.disc);
            chan = dn.disc.getChannel();
            addChannel(chan);
        }
    }
79046
private function addClassDocComment(Class_ $node, \ReflectionClass $class) : Class_
    {
        $docComment = $class->getDocComment();
        if ($docComment) {
            $node->setDocComment(new Doc($docComment));
        }

        return $node;
    }
893421
private function addDiscriminatorColumnDefinition($class, Table $table)
    {
        $discrColumn     = $class->discriminatorColumn;
        $discrColumnType = $discrColumn->getTypeName();
        $options         = [
            'notnull' => ! $discrColumn->isNullable(),
        ];

        switch ($discrColumnType) {
            case 'string':
                $options['length'] = $discrColumn->getLength() ?? 255;
                break;

            case 'decimal':
                $options['scale']     = $discrColumn->getScale();
                $options['precision'] = $discrColumn->getPrecision();
                break;
        }

        if (! empty($discrColumn->getColumnDefinition())) {
            $options['columnDefinition'] = $discrColumn->getColumnDefinition();
        }

        $table->addColumn($discrColumn->getColumnName(), $discrColumnType, $options);
    }
1052096
private function conditional_load(string $key, string $class)
    {
        if (Config::get($key) === true) {
            $this->class_list[] = $class;
        }
    }
1212341
public function classify(ReflectionClass $class)
    {
        $mergedClassifiers = array_merge(
            self::DEFAULT_CLASSIFIER,
            config('stats.custom_component_classifier', [])
        );

        foreach ($mergedClassifiers as $classifier) {
            $c = new $classifier();

            if (! $this->implementsContract($classifier)) {
                throw new Exception("Classifier {$classifier} does not implement ".ClassifierContract::class.'.');
            }

            try {
                $satisfied = $c->satisfies($class);
            } catch (Exception $e) {
                $satisfied = false;
            }

            if ($satisfied) {
                return $c->getName();
            }
        }

        return 'Other';
    }