Completed
Pull Request — master (#38)
by Sam
03:11
created

Subscription::parseNetwork()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 0
cts 8
cp 0
rs 9.7666
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 12
1
<?php
2
3
namespace Jalle19\StatusManager\Database;
4
5
use Jalle19\StatusManager\Database\Base\Subscription as BaseSubscription;
6
use Jalle19\tvheadend\model\multiplex\Multiplex;
7
use Jalle19\tvheadend\model\network\Network;
8
use Jalle19\tvheadend\model\SubscriptionStatus;
9
10
/**
11
 * @package   Jalle19\StatusManager\Database
12
 * @copyright Copyright &copy; Sam Stenvall 2015-
13
 * @license   https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0
14
 */
15
class Subscription extends BaseSubscription
16
{
17
18
	/**
19
	 * @param SubscriptionStatus $subscriptionStatus
20
	 * @param Multiplex[]        $availableMuxes
21
	 *
22
	 * @return string
23
	 */
24 View Code Duplication
	public static function parseMux(SubscriptionStatus $subscriptionStatus, array $availableMuxes)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
	{
26
		$service = $subscriptionStatus->service;
27
28
		// Check if the service string contains /$mux/
29
		foreach ($availableMuxes as $mux)
30
		{
31
			if (strpos($service, '/' . $mux->name . '/') !== false)
32
			{
33
				return $mux->name;
34
			}
35
		}
36
37
		return null;
38
	}
39
40
41
	/**
42
	 * @param SubscriptionStatus $subscriptionStatus
43
	 * @param Network[]          $availableNetworks
44
	 *
45
	 * @return string
46
	 */
47 View Code Duplication
	public static function parseNetwork(SubscriptionStatus $subscriptionStatus, array $availableNetworks)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
	{
49
		$service = $subscriptionStatus->service;
50
51
		// Check if the service string contains /$network/
52
		foreach ($availableNetworks as $network)
53
		{
54
			if (strpos($service, '/' . $network->networkname . '/') !== false)
55
			{
56
				return $network->networkname;
57
			}
58
		}
59
60
		return null;
61
	}
62
}
63