<commit_before><?php
/**
 * Uthando CMS (http://www.shaunfreeman.co.uk/)
 *
 * @author      <NAME> <<EMAIL>>
 * @link        https://github.com/uthando-cms for the canonical source repository
 * @copyright   Copyright (c) 2017 <NAME>. (http://www.shaunfreeman.co.uk)
 * @license     see LICENSE
 */

namespace UthandoNews\View;

use UthandoCommon\View\AbstractViewHelper;
use UthandoNews\Service\News as NewsService;

/**
 * Class RecentNews
 *
 * @package UthandoNews\View
 */
class NewsHelper extends AbstractViewHelper
{
    /**
     * @var NewsService
     */
    protected $service;

    /**
     * @return NewsHelper
     */
    public function __invoke()
    {
        return $this;
    }

    /**
     * @return \Zend\Db\ResultSet\HydratingResultSet|\Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
     */
    public function getPopular()
    {
        return $this->getService()
            ->getPopularNews(5);
    }

    /**
     * @return \Zend\Db\ResultSet\HydratingResultSet|\Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
     */
    public function getRecent()
    {
        return $this->getService()
            ->getRecentNews(5);
    }

    /**
     * @return NewsService
     */
    public function getService()
    {
        if (!$this->service instanceof NewsService) {

            $service = $this->getServiceLocator()
                ->getServiceLocator()
                ->get('UthandoServiceManager')<commit_msg>added next and previous helper methods<commit_after><?php
/**
 * Uthando CMS (http://www.shaunfreeman.co.uk/)
 *
 * @author      <NAME> <<EMAIL>>
 * @link        https://github.com/uthando-cms for the canonical source repository
 * @copyright   Copyright (c) 2017 <NAME>. (http://www.shaunfreeman.co.uk)
 * @license     see LICENSE
 */

namespace UthandoNews\View;

use UthandoCommon\View\AbstractViewHelper;
use UthandoNews\Model\News as NewsModel;
use UthandoNews\Service\News as NewsService;

/**
 * Class RecentNews
 *
 * @package UthandoNews\View
 */
class NewsHelper extends AbstractViewHelper
{
    /**
     * @var NewsService
     */
    protected $service;

    /**
     * @return NewsHelper
     */
    public function __invoke()
    {
        return $this;
    }

    /**
     * @return \Zend\Db\ResultSet\HydratingResultSet|\Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
     */
    public function getPopular()
    {
        return $this->getService()
            ->getPopularNews(5);
    }

    /**
     * @return \Zend\Db\ResultSet\HydratingResultSet|\Zend\Db\ResultSet\ResultSet|\Zend\Paginator\Paginator
     */
    public function getRecent()
    {
        return $this->getService()
            ->getRecentNews(5);
    }

    /**
     * @param $id
     * @return NewsModel
     */
    public function getPrevious($id): NewsModel
    {
        $prev = $this->getService()->getMapper()
            ->getPrevious($id);

        return $prev;
    }

    /**
     * @param $id
     * @return NewsModel
     */
    public function getNext($id): NewsModel
    {
        $next = $this->getService()->getMapper()
            ->getNext($id);

        return $next;
    }

    /**
     * @return NewsService
     */
    public function getService()
    {
        if (!$this->service instanceof NewsService) {

            $service = $this->getServiceLocator()
                ->getServiceLocator()
                ->get('UthandoServiceManager')
{'fraction_non_alphanumeric': 0.13678968951376685, 'fraction_numerical': 0.0035149384885764497, 'mean_word_length': 2.2216981132075473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '956085', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1047, 'n_words': 192}