<?php
namespace SabaiApps\Directories\Component\WordPressUser\EntityType;

use SabaiApps\Directories\Component\User\EntityType\AbstractUserEntity;

class UserEntity extends AbstractUserEntity {

	public function __construct( $user ) {
		parent::__construct(
			array(
				'user_email'      => $user->user_email,
				'user_url'        => $user->user_url,
				'user_registered' => strtotime( $user->user_registered ),
				'user_id'         => $user->ID,
				'user_title'      => $user->display_name,
				'user_slug'       => $user->user_nicename,
				'user_first_name' => $user->first_name,
				'user_last_name'  => $user->last_name,
			)
		);
	}

	public function getId() {
		return $this->_properties['user_id'];
	}

	public function getTitle() {
		return $this->_properties['user_title'];
	}

	public function getSlug() {
		return $this->_properties['user_slug'];
	}

	public function getEmail() {
		return $this->_properties['user_email'];
	}

	public function getUrl() {
		return $this->_properties['user_url'];
	}

	public function getTimestamp() {
		return $this->_properties['user_registered'];
	}

	public function getContent() {
		return get_user_meta( $this->_properties['user_id'], 'description', true );
	}

	public function user() {
		return get_user_by( 'ID', $this->_properties['user_id'] );
	}

	public function getFirstName() {
		return $this->_properties['user_first_name'];
	}

	public function getLastName() {
		return $this->_properties['user_last_name'];
	}

	public function getAuthorId() {
		return $this->getId();
	}
}
