@param array $data
@param array $context

@throws \ApiPlatform\Core\Exception\InvalidArgumentException
@throws \ApiPlatform\Core\Exception\PropertyNotFoundException
@throws \ApiPlatform\Core\Exception\ResourceClassNotFoundException
499597
protected function updateObjectToPopulate(array $data, array &$context)
    {
        try {
            $context['object_to_populate'] = $this->iriConverter->getItemFromIri(
                (string) $data['id'],
                $context + ['fetch_data' => false]
            );
        } catch (InvalidArgumentException $e) {
            $identifier = null;
            $properties = $this->propertyNameCollectionFactory->create($context['resource_class'], $context);
            foreach ($properties as $propertyName) {
                if ($this->propertyMetadataFactory->create($context['resource_class'], $propertyName)->isIdentifier()) {
                    $identifier = $propertyName;
                    break;
                }
            }

            if (null === $identifier) {
                throw $e;
            }

            $context['object_to_populate'] = $this->iriConverter->getItemFromIri(
                sprintf(
                    '%s/%s',
                    $this->iriConverter->getIriFromResourceClass($context['resource_class']),
                    $data[$identifier]
                ),
                $context + ['fetch_data' => false]
            );
        }
    }
422533
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
    {
        if (!($_class = $this->getClassFromArray($data))) {
            return parent::denormalizeProperty($data, $class, $name, $format, $context);
        }

        $class = $_class;
        if (!$this->serializer instanceof DenormalizerInterface) {
            $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
            throw new RuntimeException(sprintf($message, $name));
        }

        return $this->serializer->denormalize($data, $class, $format, $context);
    }
901954
public function process_legacy_resource(array $data, array $raw = null) {

        // get the course module id and context id
        $instanceid = $data['id'];
        $cminfo     = $this->get_cminfo($instanceid, 'resource');
        $moduleid   = $cminfo['id'];
        $contextid  = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);

        // prepare the new url instance record
        $url                 = array();
        $url['id']           = $data['id'];
        $url['name']         = $data['name'];
        $url['intro']        = $data['intro'];
        $url['introformat']  = $data['introformat'];
        $url['externalurl']  = $data['reference'];
        $url['timemodified'] = $data['timemodified'];

        // populate display and displayoptions fields
        $options = array('printintro' => 1);
        if ($data['options'] == 'frame') {
            $url['display'] = RESOURCELIB_DISPLAY_FRAME;

        } else if ($data['options'] == 'objectframe') {
            $url['display'] = RESOURCELIB_DISPLAY_EMBED;

        } else if ($data['popup']) {
            $url['display'] = RESOURCELIB_DISPLAY_POPUP;
            $rawoptions = explode(',', $data['popup']);
            foreach ($rawoptions as $rawoption) {
                list($name, $value) = explode('=', trim($rawoption), 2);
                if ($value > 0 and ($name == 'width' or $name == 'height')) {
                    $options['popup'.$name] = $value;
                    continue;
                }
            }

        } else {
            $url['display'] = RESOURCELIB_DISPLAY_AUTO;
        }
        $url['displayoptions'] = serialize($options);

        // populate the parameters field
        $parameters = array();
        if ($data['alltext']) {
            $rawoptions = explode(',', $data['alltext']);
            foreach ($rawoptions as $rawoption) {
                list($variable, $parameter) = explode('=', trim($rawoption), 2);
                $parameters[$parameter] = $variable;
            }
        }
        $url['parameters'] = serialize($parameters);

        // convert course files embedded into the intro
        $this->fileman = $this->converter->get_file_manager($contextid, 'mod_url', 'intro');
        $url['intro'] = moodle1_converter::migrate_referenced_files($url['intro'], $this->fileman);

        // write url.xml
        $this->open_xml_writer("activities/url_{$moduleid}/url.xml");
        $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid,
            'modulename' => 'url', 'contextid' => $contextid));
        $this->write_xml('url', $url, array('/url/id'));
        $this->xmlwriter->end_tag('activity');
        $this->close_xml_writer();

        // write inforef.xml
        $this->open_xml_writer("activities/url_{$moduleid}/inforef.xml");
        $this->xmlwriter->begin_tag('inforef');
        $this->xmlwriter->begin_tag('fileref');
        foreach ($this->fileman->get_fileids() as $fileid) {
            $this->write_xml('file', array('id' => $fileid));
        }
        $this->xmlwriter->end_tag('fileref');
        $this->xmlwriter->end_tag('inforef');
        $this->close_xml_writer();
    }
154233
private function serialize($data, TypeMetadataInterface $type, ContextInterface $context)
    {
        $class = $type->getName();

        if (!$data instanceof $class) {
            throw new \InvalidArgumentException(sprintf(
                'Expected a "%s", got "%s".',
                $class,
                is_object($data) ? get_class($data) : gettype($data)
            ));
        }

        $result = $data->format($format = $type->getOption('format', $this->format));

        if ($result === false) {
            throw new \InvalidArgumentException(sprintf('The date format "%s" is not valid.', $format));
        }

        return $result;
    }
1173851
public static function decode($data, array $context = [])
    {
        $context = array_merge(static::$defaultDecodeContext, $context);

        return static::decodeData($data, $context);
    }
956136
public static function setContextData(array $contextData = [])
    {
        $coroutineId = self::getcoroutine();
        self::$coroutineLocal[$coroutineId][self::COROUTINE_DATA] = $contextData;
    }
775286
protected function setData($data)
    {
        $data = (array) json_decode($data, true);

        if (false === array_key_exists('data', $data)) {
            throw new \InvalidArgumentException('Provided JSON has no `data` member defined');
        }

        $this->data = $data['data'];

        if (!empty($data['included'])) {
            $this->include = $data['included'];
        }
    }
542606
public function respond($event, array $data = [])
    {
        $event = (string) $event;

        if (strpos($event, '.') == false) {
            throw new \InvalidArgumentException('The event name is invalid (expecting "action.event")');
        }

        foreach ($this->listeners as $pattern => $listener) {
            if (self::match($pattern, $event)) {
                call_user_func($listener, $data, $event);
            }
        }
    }
978130
private function setProperties(array $data)
    {
        foreach ($data as $key => $value) {
            $this->setProperty($key, $value);
        }

        return $this;
    }
118236
public function setData(array $data)
    {
        $data = $this->setIdFromData($data);

        parent::setData($data);
        return $this;
    }
1229801
public static function encode($data, array $context = [])
    {
        $context = array_merge(static::$defaultEncodeContext, $context);

        return static::encodeData($data, $context);
    }
698532
public function withValues($data)
    {
        $copy = $this->values;
        foreach ($data as $key => $value) {
            $copy[$key] = $value;
        }
        return new Context($copy);
    }
1278281
public function denormalize($data, $class, $format = null, array $context = [])
    {
        /** @var \Apigee\Edge\Api\Monetization\Entity\AcceptedRatePlanInterface $denormalized */
        $denormalized = parent::denormalize($data, $class, $format, $context);

        $this->fixTimeZoneOnDenormalization($data, $denormalized, $denormalized->getRatePlan()->getPackage()->getOrganization()->getTimezone());

        return $denormalized;
    }
391860
public function render(array $data, ContextInterface $context)
    {
        $data = optionsParser($data, [
            'name' => '',
            'val' => null,
            'type' => 'text',
            'escape' => true,
            'templateVars' => [],
        ]);
        $data->add('value', $data->consume('val'));

        return $this->_templates->format('hidden', [
            'name' => $data->get('name'),
            'type' => $data->get('type'),
            'templateVars' => $data->get('templateVars'),
            'attrs' => $this->_templates->formatAttributes($data->toArray(), ['name', 'type']),
        ]);
    }
1359429
public function denormalize($data, $class, $format = null, array $context = [])
    {
        if (!preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
            throw new NotNormalizableValueException('The provided "data:" URI is not valid.');
        }

        try {
            switch ($class) {
                case 'Symfony\Component\HttpFoundation\File\File':
                    return new File($data, false);

                case 'SplFileObject':
                case 'SplFileInfo':
                    return new \SplFileObject($data);
            }
        } catch (\RuntimeException $exception) {
            throw new NotNormalizableValueException($exception->getMessage(), $exception->getCode(), $exception);
        }

        throw new InvalidArgumentException(sprintf('The class parameter "%s" is not supported. It must be one of "SplFileInfo", "SplFileObject" or "Symfony\Component\HttpFoundation\File\File".', $class));
    }
1194559
private function filterIbmWatsonSpecificErrors(array $data)
    {
        if (isset($data['error']) && $error = $data['error']) {
            if (!empty($data['code_description'])) {
                $error = "{$data['code_description']}: $error";
            }

            throw new BadResponseContextException($error, (int)$data['code'] ?? 0);
        }
    }
787581
public static function fromArray(array $data): self
    {
        if (!array_key_exists('token', $data)) {
            throw new InvalidArgumentException('Missing field "token"');
        }

        $message = self::create($data['token']);

        if ($data['data'] ?? null) {
            $message = $message->withData($data['data']);
        }

        if ($data['notification'] ?? null) {
            $message = $message->withNotification(Notification::fromArray($data['notification']));
        }

        if ($data['android'] ?? null) {
            $message = $message->withAndroidConfig(AndroidConfig::fromArray($data['android']));
        }

        if ($data['apns'] ?? null) {
            $message = $message->withApnsConfig(ApnsConfig::fromArray($data['apns']));
        }

        if ($data['webpush'] ?? null) {
            $message = $message->withWebPushConfig(WebPushConfig::fromArray($data['webpush']));
        }

        return $message;
    }