Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
9 / 9
CRAP
100.00% covered (success)
100.00%
22 / 22
XMLIndexPart
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
9 / 9
9
100.00% covered (success)
100.00%
22 / 22
 fromXML
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 toXML
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 fromIndexPartMetaData
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 getColumnName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setColumnName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getSortOrder
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setSortOrder
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getLength
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setLength
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
declare(strict_types = 1);
namespace Siesta\XML;
use Siesta\Database\MetaData\IndexPartMetaData;
/**
 * @author Gregor Müller
 */
class XMLIndexPart
{
    const ELEMENT_INDEX_PART_NAME = "indexPart";
    const COLUMN_NAME = "columnName";
    const SORT_ORDER = "sortOrder";
    const LENGTH = "length";
    /**
     * @var string
     */
    protected $columnName;
    /**
     * @var string
     */
    protected $sortOrder;
    /**
     * @var int
     */
    protected $length;
    /**
     * @param XMLAccess $xmlAccess
     */
    public function fromXML(XMLAccess $xmlAccess)
    {
        $this->setColumnName($xmlAccess->getAttribute(self::COLUMN_NAME));
        $this->setLength($xmlAccess->getAttributeAsInt(self::LENGTH));
        $this->setSortOrder($xmlAccess->getAttribute(self::SORT_ORDER));
    }
    /**
     * @param XMLWrite $parent
     */
    public function toXML(XMLWrite $parent)
    {
        $xmlWrite = $parent->appendChild(self::ELEMENT_INDEX_PART_NAME);
        $xmlWrite->setAttribute(self::COLUMN_NAME, $this->getColumnName());
        $xmlWrite->setIntAttribute(self::LENGTH, $this->getLength());
        $xmlWrite->setAttribute(self::SORT_ORDER, $this->getSortOrder());
    }
    /**
     * @param IndexPartMetaData $indexPartMetaData
     */
    public function fromIndexPartMetaData(IndexPartMetaData $indexPartMetaData)
    {
        $this->setColumnName($indexPartMetaData->getColumnName());
        $this->setLength($indexPartMetaData->getLength());
        $this->setSortOrder($indexPartMetaData->getSortOrder());
    }
    /**
     * @return string
     */
    public function getColumnName()
    {
        return $this->columnName;
    }
    /**
     * @param string $columnName
     */
    public function setColumnName($columnName)
    {
        $this->columnName = $columnName;
    }
    /**
     * @return string
     */
    public function getSortOrder()
    {
        return $this->sortOrder;
    }
    /**
     * @param string $sortOrder
     */
    public function setSortOrder($sortOrder)
    {
        $this->sortOrder = $sortOrder;
    }
    /**
     * @return int
     */
    public function getLength()
    {
        return $this->length;
    }
    /**
     * @param int $length
     */
    public function setLength($length)
    {
        $this->length = $length;
    }
}