for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Mvc\Sections;
/**
* Class SectionDetector
* @package Nip\Mvc\Sections
*/
class SectionDetector
{
* @param SectionsCollection $collection
* @return string
public static function run($collection)
$detector = new static();
return $detector->detect($collection);
return $detector->detect($collection)
boolean
string
}
* @param $collection
* @return bool|int|mixed|string
public function detect($collection)
$current = $this->detectFromConstant();
if ($current) {
$current
false
return $current;
$current = $this->detectFromSubdomain($collection);
return 'main';
* @return bool|string
protected function detectFromConstant()
return false;
// return (defined('SPORTIC_SECTION')) ? SPORTIC_SECTION : false;
* @return bool|mixed
protected function detectFromSubdomain($collection)
$subDomain = $this->getCurrentSubdomain();
foreach ($collection as $key => $section) {
if ($subDomain == $section->getSubdomain()) {
return $key;
return $subDomain;
protected function getCurrentSubdomain()
return request()->getHttp()->getSubdomain();