for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Helix\Shopify\Base\AbstractEntity;
use Helix\Shopify\Base\AbstractEntity;
use Helix\Shopify\Metafield;
/**
* Adds metafields to an entity.
*
* @see https://help.shopify.com/en/api/reference/metafield
* @mixin AbstractEntity
*/
trait MetafieldTrait {
* @return string
protected function _metafieldType (): string {
return static::TYPE;
Helix\Shopify\Base\Abstr...ty\MetafieldTrait::TYPE
}
* @return Metafield[]
public function getMetafields () {
assert($this->hasId());
hasId()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
assert($this->/** @scrutinizer ignore-call */ hasId());
// the endpoints are all over the place.
// querying the main directory works for all entities.
$remote = $this->api->get('metafields', [
'metafield[owner_id]' => $this->getId(),
getId()
'metafield[owner_id]' => $this->/** @scrutinizer ignore-call */ getId(),
'metafield[owner_resource]' => $this->_metafieldType()
]);
/** @var AbstractEntity $that */
$that = $this;
return $this->api->factoryAll($that, Metafield::class, $remote['metafields']);
* Factory.
* @return Metafield
public function newMetafield () {
return $this->api->factory($that, Metafield::class, [
'owner_resource' => $this->_metafieldType(),
'owner_id' => $this->getId()