AbstractCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSiteItems() 0 14 4
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package laravel
7
 * @subpackage Command
8
 */
9
10
11
namespace Aimeos\Shop\Command;
12
13
use Illuminate\Console\Command;
14
use Symfony\Component\Console\Input\InputOption;
15
use Symfony\Component\Console\Input\InputArgument;
16
17
18
/**
19
 * Common base class for all commands
20
 * @package laravel
21
 * @subpackage Command
22
 */
23
abstract class AbstractCommand extends Command
24
{
25
	/**
26
	 * Returns the enabled site items which may be limited by the input arguments.
27
	 *
28
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
29
	 * @param string|array $sites Unique site codes
30
	 * @return \Aimeos\MShop\Locale\Item\Site\Iface[] List of site items
31
	 */
32
	protected function getSiteItems( \Aimeos\MShop\Context\Item\Iface $context, $sites )
33
	{
34
		$manager = \Aimeos\MShop::create( $context, 'locale/site' );
35
		$search = $manager->createSearch();
36
37
		if( is_scalar( $sites ) && $sites != '' ) {
38
			$sites = explode( ' ', $sites );
39
		}
40
41
		if( !empty( $sites ) ) {
42
			$search->setConditions( $search->compare( '==', 'locale.site.code', $sites ) );
43
		}
44
45
		return $manager->searchItems( $search );
46
	}
47
}