Conditions | 3 |
Paths | 3 |
Total Lines | 52 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
44 | public function __construct( \Aimeos\MShop\Service\Provider\Iface $provider, |
||
45 | \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Service\Item\Iface $serviceItem ) |
||
46 | { |
||
47 | parent::__construct( $provider, $context, $serviceItem ); |
||
48 | |||
49 | $manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier' ); |
||
50 | $addrManager = \Aimeos\MShop\Factory::createManager( $context, 'supplier/address' ); |
||
51 | |||
52 | $search = $manager->createSearch( true ); |
||
53 | $search->setSortations( [$search->sort( '+', 'supplier.label' )] ); |
||
54 | |||
55 | foreach( $manager->searchItems( $search, ['supplier/address'] ) as $item ) |
||
56 | { |
||
57 | $addresses = $item->getAddressItems(); |
||
58 | |||
59 | if( ( $addr = reset( $addresses ) ) === false ) { |
||
60 | $addr = $addrManager->createItem(); |
||
61 | } |
||
62 | |||
63 | $this->feConfig['supplier.code']['default'][$item->getCode()] = preg_replace( "/\n+/m", "\n", sprintf( |
||
64 | |||
65 | /// Supplier address format with label (%1$s), company (%2$s), |
||
66 | /// address part one (%3$s, e.g street), address part two (%4$s, e.g house number), address part three (%5$s, e.g additional information), |
||
67 | /// postal/zip code (%6$s), city (%7$s), state (%8$s), country ID (%9$s), |
||
68 | /// e-mail (%10$s), phone (%11$s), facsimile/telefax (%12$s), web site (%13$s) |
||
69 | $context->getI18n()->dt( 'mshop', '%1$s |
||
70 | %2$s |
||
71 | %3$s %4$s |
||
72 | %5$s |
||
73 | %6$s %7$s |
||
74 | %8$s %9$s |
||
75 | %10$s |
||
76 | %11$s |
||
77 | %12$s |
||
78 | %13$s |
||
79 | ' ), |
||
80 | $item->getLabel(), |
||
81 | $addr->getCompany(), |
||
82 | $addr->getAddress1(), |
||
83 | $addr->getAddress2(), |
||
84 | $addr->getAddress3(), |
||
85 | $addr->getPostal(), |
||
86 | $addr->getCity(), |
||
87 | $addr->getState(), |
||
88 | $addr->getCountryId(), |
||
89 | $addr->getEmail(), |
||
90 | $addr->getTelephone(), |
||
91 | $addr->getTelefax(), |
||
92 | $addr->getWebsite() |
||
93 | ) ); |
||
94 | } |
||
95 | } |
||
96 | |||
147 |