<commit_before><?php

namespace Flagbit\Plantuml\TokenReflection;

use TokenReflection\IReflectionClass;

class ClassWriter extends WriterAbstract
{
    /**
     * @var \Flagbit\Plantuml\TokenReflection\ConstantWriter
     */
    private $constantWriter;

    /**
     * @var \Flagbit\Plantuml\TokenReflection\PropertyWriter
     */
    private $propertyWriter;

    /**
     * @var \Flagbit\Plantuml\TokenReflection\MethodWriter
     */
    private $methodWriter;

    public function __construct()
    {
        $this->setIndent('');
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\ConstantWriter $constantWriter
     */
    public function setConstantWriter($constantWriter)
    {
        $this->constantWriter = $constantWriter;
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\MethodWriter $methodWriter
     */
    public function setMethodWriter($methodWriter)
    {
        $this->methodWriter = $methodWriter;
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\PropertyWriter $propertyWriter
     */
    public function setPropertyWriter($propertyWriter)
    {
        $this->propertyWriter = $propertyWriter;
    }

    /**
     * @param \TokenReflection\IReflectionClass $class
     * @return string
     */
    public function writeElement(IReflectionClass $class)
    {
        $classString = $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' {');

        if ($this->constantWriter) {
            $classString .= $this->constantWriter->writeElements($class->getConstantReflections());
        }

        if ($this->propertyWriter) {
            $classString .= $this->propertyWriter->writeElements($class->getProperties());
        }

        if ($this->methodWriter) {
            $classString .= $this->methodWriter->writeElements($class->getMethods());
        }

        $classString .= $this->formatLine('}');

        if ($class->getParentClassName()) {
            $classString .= $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' extends ' . $this->formatClassName($class->getParentClassName()));
        }

        if ($class->getInterfaceNames()) {
            foreach ($class->getInterfaceNames() as $interfaceName) {
                $classString .= $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' implements ' . $this->formatClassName($interfaceName));
            }
        }

        return $classString;
    }
}<commit_msg>[+FEATURE] Omit parent class interfaces if parent class present<commit_after><?php

namespace Flagbit\Plantuml\TokenReflection;

use TokenReflection\IReflectionClass;

class ClassWriter extends WriterAbstract
{
    /**
     * @var \Flagbit\Plantuml\TokenReflection\ConstantWriter
     */
    private $constantWriter;

    /**
     * @var \Flagbit\Plantuml\TokenReflection\PropertyWriter
     */
    private $propertyWriter;

    /**
     * @var \Flagbit\Plantuml\TokenReflection\MethodWriter
     */
    private $methodWriter;

    public function __construct()
    {
        $this->setIndent('');
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\ConstantWriter $constantWriter
     */
    public function setConstantWriter($constantWriter)
    {
        $this->constantWriter = $constantWriter;
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\MethodWriter $methodWriter
     */
    public function setMethodWriter($methodWriter)
    {
        $this->methodWriter = $methodWriter;
    }

    /**
     * @param \Flagbit\Plantuml\TokenReflection\PropertyWriter $propertyWriter
     */
    public function setPropertyWriter($propertyWriter)
    {
        $this->propertyWriter = $propertyWriter;
    }

    /**
     * @param \TokenReflection\IReflectionClass $class
     * @return string
     */
    public function writeElement(IReflectionClass $class)
    {
        $classString = $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' {');

        if ($this->constantWriter) {
            $classString .= $this->constantWriter->writeElements($class->getConstantReflections());
        }

        if ($this->propertyWriter) {
            $classString .= $this->propertyWriter->writeElements($class->getProperties());
        }

        if ($this->methodWriter) {
            $classString .= $this->methodWriter->writeElements($class->getMethods());
        }

        $classString .= $this->formatLine('}');

        if ($class->getParentClassName()) {
            $classString .= $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' extends ' . $this->formatClassName($class->getParentClassName()));
        }

        if ($interfaceNames = $class->getInterfaceNames()) {
            if ($class->getParentClass()) {
                $interfaceNames = array_diff($interfaceNames, $class->getParentClass()->getInterfaceNames());
            }

            foreach ($interfaceNames as $interfaceName) {
                $classString .= $this->formatLine('class ' . $this->formatClassName($class->getName()) . ' implements ' . $this->formatClassName($interfaceName));
            }
        }

        return $classString;
    }
}
{'fraction_non_alphanumeric': 0.14172313649564375, 'fraction_numerical': 0.0, 'mean_word_length': 2.67425320056899, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3013774', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1375, 'n_words': 204}