{layout '@layout.latte'}
{var $active = 'class'}

{block title}{if $class->deprecated}Deprecated {/if}{if $class->interface}Interface{elseif $class->trait}Trait{else}Class{/if} {$class->name}{/block}

{block content}
<div id="content" class="class">

    <div class="page-header">
        <h1 n:class="$class->deprecated ? deprecated">{if $class->interface}Interface{elseif $class->trait}Trait{else}Class{/if} {$class->shortName}</h1>
    </div>

    {if $class->valid}

    <dl class="tree well" n:if="$class->parentClass || $class->ownInterfaces || $class->ownTraits">
        <dd n:foreach="$tree as $item" style="padding-left:{($iterator->counter - 1) * 30}px">
            <img src="resources/inherit.png" alt="Extended by" n:if="$iterator->counter > 1">
            {if $item->documented}
            <a href="{$item|classUrl}" n:tag-if="!$iterator->last">{last}<b>{/last}<span n:class="$item->deprecated ? deprecated, !$item->valid ? invalid">{$item->name}</span>{last}</b>{/last}</a>
            {else}{$item->name}{/if}
            {var $itemOwnInterfaces = $item->ownInterfaces}
            {if $itemOwnInterfaces} implements {foreach $itemOwnInterfaces as $interface}
                <a href="{$interface|classUrl}" n:tag-if="$interface->documented"><span n:class="$interface->deprecated ? deprecated, !$interface->valid ? invalid">{$interface->name}</span></a>{sep}, {/sep}
            {/foreach}{/if}
            {var $itemOwnTraits = $item->ownTraits}
            {if $itemOwnTraits} uses {foreach $itemOwnTraits as $trait}
                {if is_string($trait)}
                    {$trait} (not available)
                {else}
                    <a href="{$trait|classUrl}" n:tag-if="$trait->documented"><span n:class="$trait->deprecated ? deprecated, !$trait->valid ? invalid">{$trait->name}</span></a>{sep}, {/sep}
                {/}
            {/foreach}{/if}
        </dd>
        {if !$class->interface && !$class->trait && ($class->abstract || $class->final)}<dd><b>{if $class->abstract}Abstract class{else}Final class{/if}</b></dd>{/if}
        {if $class->inNamespace()}<dd><b>Namespace:</b> {$class->namespaceName|namespaceLinks|noescape}</dd>{/if}
        {if $class->internal}<dd><b>PHP Extension:</b> <a href="{$class->extension|manualUrl}" title="Go to PHP documentation">{$class->extension->name|firstUpper}</a></dd>{/if}
        {foreach $template->annotationSort($template->annotationFilter($class->annotations)) as $annotation => $values}
            {foreach $values as $value}
                <dd><b>{$annotation|annotationBeautify}{if $value}:{/if}</b>
                {$value|annotation:$annotation:$class|noescape}</dd>
            {/foreach}
        {/foreach}
        {if $class->internal}
            <dd><b>Documented at</b> <a href="{$class|manualUrl}" title="Go to PHP documentation">php.net</a></dd>
        {else}
            <dd><b>Located at</b> <a n:tag-if="$config->sourceCode" href="{$class|sourceUrl}" title="Go to source code">{$class->fileName|relativePath}</a><dd>
        {/if}
    </dl>

    <div class="description" n:if="$template->longDescription($class)">
        {$class|longDescription|noescape}
    </div>

    {define children}
        <p class="csv-list">
        {foreach $children as $child}
            <code><a href="{$child|classUrl}" n:tag-if="$child->documented"><span n:tag-if="$child->deprecated" class="deprecated">{$child->name}</span></a></code>{sep}, {/sep}
        {/foreach}
        </p>
    {/define}

    <div n:if="$directSubClasses">
        <h3>Direct known subclasses</h3>
        {include children, children => $directSubClasses}
    </div>

    <div n:if="$indirectSubClasses">
        <h3>Indirect known subclasses</h3>
        {include children, children => $indirectSubClasses}
    </div>

    <div n:if="$directImplementers">
        <h3>Direct known implementers</h3>
        {include children, children => $directImplementers}
    </div>

    <div n:if="$indirectImplementers">
        <h3>Indirect known implementers</h3>
        {include children, children => $indirectImplementers}
    </div>

    <div n:if="$directUsers">
        <h3>Direct Known Users</h3>
        {include children, children => $directUsers}
    </div>

    <div n:if="$indirectUsers">
        <h3>Indirect Known Users</h3>
        {include children, children => $indirectUsers}
    </div>

    {var $ownMethods = $class->ownMethods}
    {var $inheritedMethods = $class->inheritedMethods}
    {var $usedMethods = $class->usedMethods}
    {var $ownMagicMethods = $class->ownMagicMethods}
    {var $inheritedMagicMethods = $class->inheritedMagicMethods}
    {var $usedMagicMethods = $class->usedMagicMethods}

    {define #short-method}
        <li>
            {var $annotations = $method->annotations}
            <a class="method-summary-link" href="#{if $method->magic}m{/if}_{$method->name}">
                {if !$class->interface && $method->abstract}abstract{elseif $method->final}final{/if} {if $method->static}static{/if}
                {if $method->returnsReference()}&amp;{/if}
                {block|strip}
                <strong>{$method->name}</strong> (
                {foreach $method->parameters as $parameter}
                    {ifset $parameter->typeHint}{$parameter->typeHint}{/ifset}
                    {if $parameter->passedByReference}&amp; {/if}${$parameter->name}{if $parameter->defaultValueAvailable} = {$parameter->defaultValueDefinition|highlightPHP:$class|noescape}{elseif $parameter->unlimited},…{/if}{sep}, {/sep}
                {/foreach})
                {/block}
            </a>
            {block|strip}<div class="summary-info">{$method|shortDescription:true|noescape}</div>{/block}
        </li>
    {/define}

    {define method}

        <div class="method-container" data-order="{$method->name}" id="{if $method->magic}m{/if}_{$method->name}">
            {var $annotations = $method->annotations}

            <h3 class="method-title">
                {if !$class->interface && $method->abstract}abstract{/if} {if $method->static}static{/if}
                {ifset $annotations['return']}{$annotations['return'][0]|typeLinks:$method|noescape}{/ifset}
                {if $method->returnsReference()}&amp;{/if}
                <strong>{$method->name}</strong> (
                {foreach $method->parameters as $parameter}
                    <span>{$parameter->typeHint|typeLinks:$method|noescape}
                    {if $parameter->passedByReference}&amp; {/if}${$parameter->name}{if $parameter->defaultValueAvailable} = {$parameter->defaultValueDefinition|highlightPHP:$class|noescape}{elseif $parameter->unlimited},…{/if}</span>{sep}, {/sep}
                {/foreach} )
            </h3>

            {if $config->template['options']['elementDetailsCollapsed']}
            <div class="description short">
                {$method|shortDescription:true|noescape}
            </div>
            {/if}

            <div n:class="description, detailed, $config->template['options']['elementDetailsCollapsed'] ? hidden">
                {$method|longDescription|noescape}

                {if !$class->deprecated && $method->deprecated}
                    <h4>Deprecated</h4>
                    {ifset $annotations['deprecated']}
                    <div class="list">
                    {foreach $annotations['deprecated'] as $description}
                        {if $description}
                            {$description|annotation:'deprecated':$method|noescape}<br>
                        {/if}
                    {/foreach}
                    </div>
                    {/ifset}
                {/if}

                {if $method->parameters && isset($annotations['param'])}
                    <h4>Parameters</h4>
                    <table class="table table-condensed">
                        {foreach $method->parameters as $parameter}
                            <tr>
                                <td class="name monospace">{$parameter->typeHint|typeLinks:$method|noescape}{if $parameter->passedByReference}&amp; {/if}</td>
                                <td class="name monospace">
                                ${$parameter->name}
                                {if $parameter->defaultValueAvailable} = {$parameter->defaultValueDefinition|highlightPHP:$class|noescape}
                                {elseif $parameter->unlimited},…{/if}
                                </td>
                                <td>{$parameter->description|description:$method|noescape}</td>
                            </tr>
                        {/foreach}
                    </table>
                {/if}

                {if isset($annotations['return']) && 'void' !== $annotations['return'][0]}
                    <h4>Returns</h4>
                    <table class="table table-condensed">
                    {foreach $annotations['return'] as $description}
                        <tr>
                            <td class="name monospace">{$description|annotation:'return':$method|noescape}</td>
                        </tr>
                    {/foreach}
                    </table>
                {/if}

                {ifset $annotations['throws']}
                    <h4>Exceptions</h4>
                    <table class="table table-condensed">
                    {foreach $annotations['throws'] as $description}
                        <tr>
                            <td>{$description|annotation:'throws':$method|noescape}</td>
                        </tr>
                    {/foreach}
                    </table>
                {/ifset}

                {foreach $template->annotationSort($template->annotationFilter($annotations, array('deprecated', 'param', 'return', 'throws'))) as $annotation => $descriptions}
                    <h4>{$annotation|annotationBeautify}</h4>
                    <div class="list">
                    {foreach $descriptions as $description}
                        {if $description}
                            {$description|annotation:$annotation:$method|noescape}<br>
                        {/if}
                    {/foreach}
                    </div>
                {/foreach}

                {var $overriddenMethod = $method->overriddenMethod}
                {if $overriddenMethod}
                    <h4>Overrides</h4>
                    <div class="list"><code><a n:tag-if="$template->getClass($overriddenMethod->declaringClassName)" href="{$overriddenMethod|methodUrl}">{$overriddenMethod->declaringClassName}::{$overriddenMethod->name}</a></code></div>
                {/if}

                {var $implementedMethod = $method->implementedMethod}
                {if $implementedMethod}
                    <h4>Implementation of</h4>
                    <div class="list"><code><a n:tag-if="$template->getClass($implementedMethod->declaringClassName)" href="{$implementedMethod|methodUrl}">{$implementedMethod->prettyName}</a></code></div>
                {/if}
            </div>
        </div>
    {/define}

    <!-- api -->

    {if $ownMethods || $inheritedMethods || $usedMethods || $ownMagicMethods || $usedMagicMethods}

        <h2>Methods Summary</h2>
        <div class="element-list" id="methods-summary">
            <ul class="methods-summary">
                {foreach $ownMethods as $method}
                    {include #short-method, method => $method}
                {/foreach}
            </ul>

            {foreach $inheritedMethods as $parentName => $methods}
            <h3 class="inherited">Methods inherited from <a href="{$parentName|classUrl}#methods" n:tag-if="$template->getClass($parentName)">{$parentName}</a></h3>
            <div class="inherited-list csv-list">
            {foreach $methods as $method}
                <code><a href="{$method|methodUrl}" n:tag-if="$template->getClass($parentName)"><span n:tag-if="$method->deprecated" class="deprecated">{$method->name}()</span></a></code>{sep}, {/sep}
            {/foreach}
            </div>
            {/foreach}

            {foreach $usedMethods as $traitName => $methods}
            <h3 class="inherited">Methods used from <a href="{$traitName|classUrl}#methods" n:tag-if="$template->getClass($traitName)">{$traitName}</a></h3>
            <div class="inherited-list csv-list">
                {foreach $methods as $data}
                    <code><a href="{$data['method']|methodUrl:$data['method']->declaringTrait}" n:tag-if="$template->getClass($traitName)"><span n:tag-if="$data['method']->deprecated" class="deprecated">{$data['method']->name}()</span></a>{if $data['aliases']}(as {foreach $data['aliases'] as $alias}<span n:tag-if="$data['method']->deprecated" class="deprecated">{$alias->name}()</span>{sep}, {/sep}{/foreach}){/if}</code>{sep}, {/sep}
                {/foreach}
            </div>
            {/foreach}

            {foreach $inheritedMagicMethods as $parentName => $methods}
            <h3 class="inherited">Magic methods inherited from <a href="{$parentName|classUrl}#methods" n:tag-if="$template->getClass($parentName)">{$parentName}</a></h3>
            <div class="inherited-list csv-list">
                {foreach $methods as $method}
                    <code><a href="{$method|methodUrl}" n:tag-if="$template->getClass($parentName)"><span n:tag-if="$method->deprecated" class="deprecated">{$method->name}()</span></a></code>{sep}, {/sep}
                {/foreach}
            </div>
            {/foreach}

            {foreach $usedMagicMethods as $traitName => $methods}
            <h3 class="inherited">Magic methods used from <a href="{$traitName|classUrl}#methods" n:tag-if="$template->getClass($traitName)">{$traitName}</a></h3>
            <div class="inherited-list csv-list">
            {foreach $methods as $data}
                <code><a href="{$data['method']|methodUrl:$data['method']->declaringTrait}" n:tag-if="$template->getClass($traitName)"><span n:tag-if="$data['method']->deprecated" class="deprecated">{$data['method']->name}()</span></a>{if $data['aliases']}(as {foreach $data['aliases'] as $alias}<span n:tag-if="$data['method']->deprecated" class="deprecated">{$alias->name}()</span>{sep}, {/sep}{/foreach}){/if}</code>{sep}, {/sep}
            {/foreach}
            </div>
            {/foreach}
        </div>

        {if $ownMethods }
        <h2>Methods Details</h2>
        <div class="element-list" id="methods" n:if="$ownMethods">
            {foreach $ownMethods as $method}
                {include method, method => $method}
            {/foreach}
        </div>
        {/if}

        {var $isAwsClient = false}
        {foreach $class->parentClasses as $parent}
            {if $parent->name === 'Aws\AwsClient'}
                {var $isAwsClient = true}
            {/if}
        {/foreach}

        {if $ownMagicMethods && !$isAwsClient}
        <h3>Magic methods summary</h3>
        <div class="element-list" id="magicMethods" n:if="$ownMagicMethods">
            {foreach $ownMagicMethods as $method}
                {include method, method => $method}
            {/foreach}
        </div>
        {/if}
    {/if}

    {var $ownConstants = $class->ownConstants}
    {var $inheritedConstants = $class->inheritedConstants}

    {if $ownConstants || $inheritedConstants}
        <h2>Constants summary</h2>
        <table class="summary table table-bordered table-striped constants" id="constants" n:if="$ownConstants">
        <tr n:foreach="$ownConstants as $constant" data-order="{$constant->name}" id="{$constant->name}">
            {var $annotations = $constant->annotations}

            <td class="attributes"><code>{$constant->typeHint|typeLinks:$constant|noescape}</code></td>
            <td class="name">
                <code>
                {if $class->internal}
                    <a href="{$constant|manualUrl}" title="Go to PHP documentation"><b>{$constant->name}</b></a>
                {else}
                    <a n:tag-if="$config->sourceCode" href="{$constant|sourceUrl}" title="Go to source code"><b>{$constant->name}</b></a>
                {/if}
                </code>

                <div n:if="$config->template['options']['elementDetailsCollapsed']" class="description short">
                    {$constant|shortDescription:true|noescape}
                </div>

                <div n:class="description, detailed, $config->template['options']['elementDetailsCollapsed'] ? hidden">
                    {$constant|longDescription|noescape}

                    {foreach $template->annotationSort($template->annotationFilter($annotations, array('var'))) as $annotation => $descriptions}
                        <h4>{$annotation|annotationBeautify}</h4>
                        <div class="list">
                        {foreach $descriptions as $description}
                            {if $description}
                                {$description|annotation:$annotation:$constant|noescape}<br>
                            {/if}
                        {/foreach}
                        </div>
                    {/foreach}
                </div>
            </td>
            <td class="value">
                <div>
                    <a href="#{$constant->name}" class="anchor">#</a>
                    <code>{$constant->valueDefinition|highlightValue:$class|noescape}</code>
                </div>
            </td>
        </tr>
        </table>

        {foreach $inheritedConstants as $parentName => $constants}
        <h3>Constants inherited from <a href="{$parentName|classUrl}#constants" n:tag-if="$template->getClass($parentName)">{$parentName}</a></h3>
        <div class="element-list">
        {foreach $constants as $constant}
            <code><a href="{$constant|constantUrl}" n:tag-if="$template->getClass($parentName)"><b><span n:tag-if="$constant->deprecated" class"deprecated">{$constant->name}</span></b></a></code>{sep}, {/sep}
        {/foreach}
        </div>
        {/foreach}

    {/if}

    {else}
        <div class="alert alert-error">
            <p>Documentation of this class could not be generated.</p>
            <p>Class was originally declared in {$class->fileName|relativePath} and is invalid because of:</p>
            <ul><li n:foreach="$class->reasons as $reason">Class was redeclared in {$reason->getSender()->getFileName()|relativePath}.</li></ul>
        </div>
    {/if}

    <!-- modeled_exceptions -->
</div>
{/block}
