<?php
namespace SabaiApps\Directories\Component\Field\Type;

use SabaiApps\Directories\Component\Field\IField;
use SabaiApps\Directories\Component\Entity\Type\IEntity;

trait ComparableStringTrait {

	protected $_comparableItemSeparator = ', ';

	abstract public function fieldHumanReadableText( IField $field, IEntity $entity, $separator = null, $key = null );

	public function fieldComparableItemLabels( IField $field ) {
		return array( '' => (string) $field->getFieldLabel() );
	}

	public function fieldComparableItemValues( IField $field, IEntity $entity, $html = true ) {
		$value = $this->fieldHumanReadableText( $field, $entity, $this->_comparableItemSeparator );
		if ( $html ) {
			$value = $this->_application->Htmlize( $value );
		}
		return array( '' => $value );
	}
}
