<commit_before><?php

namespace Phpro\SoapClient\CodeGenerator\Assembler;

use Phpro\SoapClient\CodeGenerator\Context\ContextInterface;
use Phpro\SoapClient\CodeGenerator\Context\TypeContext;
use Phpro\SoapClient\Exception\AssemblerException;
use Zend\Code\Generator\ClassGenerator;

/**
 * Class ExtendAssembler
 *
 * @package Phpro\SoapClient\CodeGenerator\Assembler
 */
class ExtendAssembler implements AssemblerInterface
{
    /**
     * @var string
     */
    private $extendedClassName;

    /**
     * ExtendedAssembler constructor.
     *
     * @param $extendedClassName
     */
    public function __construct($extendedClassName)
    {
        $this->extendedClassName = $extendedClassName;
    }

    /**
     * @param ContextInterface $context
     *
     * @return bool
     */
    public function canAssemble(ContextInterface $context)
    {
        return $context instanceof TypeContext;
    }

    /**
     * @param ContextInterface|TypeContext $context
     */
    public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $extendedClassName = $this->extendedClassName;

        if ($this->isExtendingItself($class)) {
            return;
        }

        try {
            $useAssembler = new UseAssembler($extendedClassName);
            if ($useAssembler->canAssemble($context)) {
                $useAssembler->assemble($context);
            }

            $class->setExtendedClass($extendedClassName);

        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }

    /**
     * @param ClassGenerator $class
     * @return bool
     */
    private function isExtendingItself(ClassGenerator $class)
    {
        $fullClassName = $class->getNamespaceName() . '\\' . $class->getName();

        return $this->extendedClassName === $fullClassName;
    }
}<commit_msg>cs fix<commit_after><?php

namespace Phpro\SoapClient\CodeGenerator\Assembler;

use Phpro\SoapClient\CodeGenerator\Context\ContextInterface;
use Phpro\SoapClient\CodeGenerator\Context\TypeContext;
use Phpro\SoapClient\Exception\AssemblerException;
use Zend\Code\Generator\ClassGenerator;

/**
 * Class ExtendAssembler
 *
 * @package Phpro\SoapClient\CodeGenerator\Assembler
 */
class ExtendAssembler implements AssemblerInterface
{
    /**
     * @var string
     */
    private $extendedClassName;

    /**
     * ExtendedAssembler constructor.
     *
     * @param $extendedClassName
     */
    public function __construct($extendedClassName)
    {
        $this->extendedClassName = $extendedClassName;
    }

    /**
     * @param ContextInterface $context
     *
     * @return bool
     */
    public function canAssemble(ContextInterface $context)
    {
        return $context instanceof TypeContext;
    }

    /**
     * @param ContextInterface|TypeContext $context
     */
    public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $extendedClassName = $this->extendedClassName;

        if ($this->isExtendingItself($class)) {
            return;
        }

        try {
            $useAssembler = new UseAssembler($extendedClassName);
            if ($useAssembler->canAssemble($context)) {
                $useAssembler->assemble($context);
            }

            $class->setExtendedClass($extendedClassName);
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }

    /**
     * @param ClassGenerator $class
     * @return bool
     */
    private function isExtendingItself(ClassGenerator $class)
    {
        $fullClassName = $class->getNamespaceName() . '\\' . $class->getName();

        return $this->extendedClassName === $fullClassName;
    }
}
{'fraction_non_alphanumeric': 0.11430090377458799, 'fraction_numerical': 0.0, 'mean_word_length': 2.5803996194100858, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '257329', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1022, 'n_words': 175}