Satisfies interface method.
Invoked in XmlSquad\Library\Application\Service\GoogleDriveProcessService
515798
public function processDomainGSheetObjects(array $inventories)
    {
        $dom = new DomDocument("1.0", "UTF-8");
        $products = $dom->createElement('Products');

        /** @var Inventory $inventory */
        foreach ($inventories as $inventory) {
            $product = $dom->createElement('Product');
            $inventoryXmlElement = $this->buildInventoryElement($dom, $inventory);
            $product->appendChild($inventoryXmlElement);
            $products->appendChild($product);
        }

        $dom->appendChild($products);

        return $this->outputFormattedXml($dom);
    }
644614
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('');

        $forcedMode = $mappingName = $input->getOption('force');
        $mappingName = $input->getOption('sheet');
        $mapping = $this->googleApiService->getMapping();
        $destination = realpath($input->getOption('destination') ?: getcwd());

        if (empty($destination)) {
            $output->writeln(sprintf('<error>The destination directory doesn\'t exist: %s</error>', $input->getOption('destination') ?: getcwd()));

            return;
        }

        if (!is_dir($destination)) {
            $output->writeln(sprintf('<error>The destination is not a valid directory: %s</error>', $destination));

            return;
        }

        if (!is_writable($destination)) {
            $output->writeln(sprintf('<error>The destination is not writable: %s</error>', $destination));

            return;
        }

        // If the mapping didn't exist, list all those which do
        if (!isset($mapping[$mappingName])) {
            $this->listKnownSheets($output);
        } else {
            $output->writeln(sprintf('<comment>Generated CSV files will be saved into %s.</comment>', $destination));
            $output->writeln('');

            // This is where we force the GoogleApiService to load a ceedentials file
            $output->writeln(sprintf(
                '<comment>Using gApiServiceAccountCredentials stored in %s.</comment>',
                $this->googleApiService->setCredentials($this->getGApiServiceAccountCredentialsFileOption($input))
            ));

            $output->writeln(sprintf(
                '<comment>Using sheet mapping file stored in %s.</comment>',
                $this->googleApiService->getMappingFilePath()
            ));
            $output->writeln('');

            $output->write('Fetching data from the Google API...');

            // The service does the API-related job and returns an array of sheets and their values together with the document name
            list($documentName, $sheets) = $this->googleApiService->loadSheets($mappingName);

            $output->writeln('done.');
            $output->writeln('');
            $output->writeln(sprintf('Document <info>%s</info> contains <info>%s</info> sheet(s). Writing CSV files now.', $documentName, count($sheets)));
            $output->writeln('');

            // Default ConfirmationQuestion action depends on the $forcedMode settings. Forced == off -> $default = false. Forced == on -> $default = true
            $default = $forcedMode ? '[Y/n]' : '[y/N]';

            // We'll be using this helper in the loop in a while, so let's fetch it just once
            $helper = $this->getHelper('question');

            foreach ($sheets as $sheetName => $sheetData) {
                // This file name is potentially dangerous. More ont hat later.
                $file = $documentName.'-'.$sheetName.'.csv';

                $output->write(sprintf('Processing file <info>%s</info>. ', $file));

                // Checks for potentially unsafe characters in the file name. If it is a risky file name, a remedy is offered.
                $regex = '~[^0-9a-z_\-\.\ ]~i';
                if (preg_match($regex, $file)) {
                    $safeFileName = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $documentName.'-'.$sheetName);
                    $safeFileName = trim(preg_replace($regex, '', $safeFileName)).'.csv';

                    // Removes multiple spaces too
                    $safeFileName = preg_replace('~\ {2,}~', ' ', $safeFileName);

                    $question = new ConfirmationQuestion(
                        sprintf("<error>A risky file name detected.</error>\nI suggest to continue with a safe file name: <comment>%s</comment>. Do you agree? %s ", $safeFileName, $default),
                        $forcedMode,
                        '/^(y|yes)/i'
                    );
                    if (!$helper->ask($input, $output, $question)) {
                        $output->writeln('<comment>Skipping (unsafe file name).</comment>');
                        continue;
                    } else {
                        $file = $safeFileName;
                        $output->write('Ok, continuing with the safe file name. ');
                    }
                }

                // At this stage we know that $file continues a safe file name - if the file name is risky and is not auto-corrected, the file is skipped.
                $path = $destination.DIRECTORY_SEPARATOR.$file;

                // Last check before overwriting the file
                if (file_exists($path)) {
                    $question = new ConfirmationQuestion(sprintf("<question>File already exists.</question>\nDo you wish to overwrite the file? %s ", $default), $forcedMode, '/^(y|yes)/i');

                    if (!$helper->ask($input, $output, $question)) {
                        $output->writeln('<comment>Skipping (file exists).</comment>');
                        continue;
                    }
                }

                // If we came here, everything either passed, or was accepted - so let's make our CSV file.
                $fp = fopen($path, 'w');
                foreach ($sheetData['values'] as $row) {
                    fputcsv($fp, $row);
                }
                fclose($fp);

                $output->writeln('<comment>Done.</comment>');
            }

            $output->writeln('');
            $output->writeln('<comment>All CSV files saved successfully.</comment>');
        }
    }
1077765
@Override
  public I get()
  {
    I instance = _instance;
    
    if (instance == null || instance.isModified()) {
      _instance = instance = service().get();
    }
    
    return instance;
  }
435598
public function execute()
    {
        $id = $this->getRequest()->getParam('id');
        if ($id) {
            $menu = $this->menuRepository->getById($id);
        } else {
            $menu = $this->menuFactory->create();
        }
        $menu->setTitle($this->getRequest()->getParam('title'));
        $menu->setIdentifier($this->getRequest()->getParam('identifier'));
        $menu->setCssClass($this->getRequest()->getParam('css_class'));
        $menu->setIsActive(1);
        $menu = $this->menuRepository->save($menu);

        if (!$id) {
            $id = $menu->getId();
        }

        $menu->saveStores($this->getRequest()->getParam('stores'));

        $nodes = $this->getRequest()->getParam('serialized_nodes');
        if (!empty($nodes)) {
            $nodes = json_decode($nodes, true);
            $nodes = $this->_convertTree($nodes, '#');

            if (!empty($nodes)) {

                $filterBuilder = $this->filterBuilderFactory->create();
                $filter = $filterBuilder->setField('menu_id')->setValue($id)->setConditionType('eq')->create();

                $filterGroupBuilder = $this->filterGroupBuilderFactory->create();
                $filterGroup = $filterGroupBuilder->addFilter($filter)->create();

                $searchCriteriaBuilder = $this->searchCriteriaBuilderFactory->create();
                $searchCriteria = $searchCriteriaBuilder->setFilterGroups([$filterGroup])->create();

                $oldNodes = $this->nodeRepository->getList($searchCriteria)->getItems();

                $existingNodes = [];
                foreach ($oldNodes as $node) {
                    $existingNodes[$node->getId()] = $node;
                }

                $nodesToDelete = [];
                foreach ($existingNodes as $nodeId => $noe) {
                    $nodesToDelete[$nodeId] = true;
                }

                $nodeMap = [];

                foreach ($nodes as $node) {
                    $nodeId = $node['id'];
                    $matches = [];
                    if (preg_match('/^node_([0-9]+)$/', $nodeId, $matches)) {
                        $nodeId = $matches[1];
                        unset($nodesToDelete[$nodeId]);
                        $nodeMap[$node['id']] = $existingNodes[$nodeId];
                    } else {
                        $nodeObject = $this->nodeFactory->create();
                        $nodeObject->setMenuId($id);
                        $nodeObject = $this->nodeRepository->save($nodeObject);
                        $nodeMap[$nodeId] = $nodeObject;
                    }
                }

                foreach (array_keys($nodesToDelete) as $nodeId) {
                    $this->nodeRepository->deleteById($nodeId);
                }

                $path = [
                    '#' => 0,
                ];
                foreach ($nodes as $node) {
                    if ($node['type'] == 'product' && !$this->validateProductNode($node)) {
                        continue;
                    }
                    $nodeObject = $nodeMap[$node['id']];

                    $parents = array_keys($path);
                    $parent = array_pop($parents);
                    while ($parent != $node['parent']) {
                        array_pop($path);
                        $parent = array_pop($parents);
                    }

                    $level = count($path) - 1;
                    $position = $path[$node['parent']]++;

                    if ($node['parent'] == '#') {
                        $nodeObject->setParentId(null);
                    } else {
                        $nodeObject->setParentId($nodeMap[$node['parent']]->getId());
                    }

                    $nodeObject->setType($node['type']);
                    if (isset($node['classes'])) {
                        $nodeObject->setClasses($node['classes']);
                    }
                    if (isset($node['content'])) {
                        $nodeObject->setContent($node['content']);
                    }
                    if (isset($node['target'])) {
                        $nodeObject->setTarget($node['target']);
                    }
                    $nodeObject->setMenuId($id);
                    $nodeObject->setTitle($node['title']);
                    $nodeObject->setIsActive(1);
                    $nodeObject->setLevel($level);
                    $nodeObject->setPosition($position);

                    $this->nodeRepository->save($nodeObject);

                    $path[$node['id']] = 0;
                }
            }
        }

        $redirect = $this->resultRedirectFactory->create();
        $redirect->setPath('*/*/index');

        if ($this->getRequest()->getParam('back')) {
            $redirect->setPath('*/*/edit', ['id' => $menu->getId(), '_current' => true]);
        }

        return $redirect;
    }
248987
public function execute() {
        global $CFG, $COMPLETION_CRITERIA_TYPES, $DB;

        if ($CFG->enablecompletion) {
            require_once($CFG->libdir . "/completionlib.php");

            // Process each criteria type.
            foreach ($COMPLETION_CRITERIA_TYPES as $type) {
                $object = 'completion_criteria_' . $type;
                require_once($CFG->dirroot . '/completion/criteria/' . $object . '.php');

                $class = new $object();
                // Run the criteria type's cron method, if it has one.
                if (method_exists($class, 'cron')) {
                    if (debugging()) {
                        mtrace('Running '.$object.'->cron()');
                    }
                    $class->cron();
                }
            }

            if (debugging()) {
                mtrace('Aggregating completions');
            }

            // Save time started.
            $timestarted = time();

            // Grab all criteria and their associated criteria completions.
            $sql = 'SELECT DISTINCT c.id AS course, cr.id AS criteriaid, crc.userid AS userid,
                                    cr.criteriatype AS criteriatype, cc.timecompleted AS timecompleted
                      FROM {course_completion_criteria} cr
                INNER JOIN {course} c ON cr.course = c.id
                INNER JOIN {course_completions} crc ON crc.course = c.id
                 LEFT JOIN {course_completion_crit_compl} cc ON cc.criteriaid = cr.id AND crc.userid = cc.userid
                     WHERE c.enablecompletion = 1
                       AND crc.timecompleted IS NULL
                       AND crc.reaggregate > 0
                       AND crc.reaggregate < :timestarted
                  ORDER BY course, userid';
            $rs = $DB->get_recordset_sql($sql, ['timestarted' => $timestarted]);

            // Check if result is empty.
            if (!$rs->valid()) {
                $rs->close();
                return;
            }

            $currentuser = null;
            $currentcourse = null;
            $completions = [];
            while (1) {
                // Grab records for current user/course.
                foreach ($rs as $record) {
                    // If we are still grabbing the same users completions.
                    if ($record->userid === $currentuser && $record->course === $currentcourse) {
                        $completions[$record->criteriaid] = $record;
                    } else {
                        break;
                    }
                }

                // Aggregate.
                if (!empty($completions)) {
                    if (debugging()) {
                        mtrace('Aggregating completions for user ' . $currentuser . ' in course ' . $currentcourse);
                    }

                    // Get course info object.
                    $info = new \completion_info((object)['id' => $currentcourse]);

                    // Setup aggregation.
                    $overall = $info->get_aggregation_method();
                    $activity = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_ACTIVITY);
                    $prerequisite = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_COURSE);
                    $role = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_ROLE);

                    $overallstatus = null;
                    $activitystatus = null;
                    $prerequisitestatus = null;
                    $rolestatus = null;

                    // Get latest timecompleted.
                    $timecompleted = null;

                    // Check each of the criteria.
                    foreach ($completions as $params) {
                        $timecompleted = max($timecompleted, $params->timecompleted);
                        $completion = new \completion_criteria_completion((array)$params, false);

                        // Handle aggregation special cases.
                        if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
                            completion_cron_aggregate($activity, $completion->is_complete(), $activitystatus);
                        } else if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
                            completion_cron_aggregate($prerequisite, $completion->is_complete(), $prerequisitestatus);
                        } else if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_ROLE) {
                            completion_cron_aggregate($role, $completion->is_complete(), $rolestatus);
                        } else {
                            completion_cron_aggregate($overall, $completion->is_complete(), $overallstatus);
                        }
                    }

                    // Include role criteria aggregation in overall aggregation.
                    if ($rolestatus !== null) {
                        completion_cron_aggregate($overall, $rolestatus, $overallstatus);
                    }

                    // Include activity criteria aggregation in overall aggregation.
                    if ($activitystatus !== null) {
                        completion_cron_aggregate($overall, $activitystatus, $overallstatus);
                    }

                    // Include prerequisite criteria aggregation in overall aggregation.
                    if ($prerequisitestatus !== null) {
                        completion_cron_aggregate($overall, $prerequisitestatus, $overallstatus);
                    }

                    // If aggregation status is true, mark course complete for user.
                    if ($overallstatus) {
                        if (debugging()) {
                            mtrace('Marking complete');
                        }

                        $ccompletion = new \completion_completion([
                            'course' => $params->course,
                            'userid' => $params->userid
                        ]);
                        $ccompletion->mark_complete($timecompleted);
                    }
                }

                // If this is the end of the recordset, break the loop.
                if (!$rs->valid()) {
                    $rs->close();
                    break;
                }

                // New/next user, update user details, reset completions.
                $currentuser = $record->userid;
                $currentcourse = $record->course;
                $completions = [];
                $completions[$record->criteriaid] = $record;
            }

            // Mark all users as aggregated.
            $sql = "UPDATE {course_completions}
                       SET reaggregate = 0
                     WHERE reaggregate < :timestarted
                       AND reaggregate > 0";
            $DB->execute($sql, ['timestarted' => $timestarted]);
        }
    }
962470
private boolean satisfies(EvaluationContext ctx, Object param, UnaryTest test ) {
        return test.apply( ctx, param );
    }
364742
private void injectWebDriver(Statement statement) {
		if (statement instanceof WebDriverAware) {
			((WebDriverAware) statement).setWebDriver(webDriverProvider.getWebDriver());
		}
	}
206700
public function build(): FulfillRequestRequest
	{
		$instance = new FulfillRequestRequest();
		if ($this->requestId === null) {
			throw new BuilderException('Property [requestId] is required.');
		}
		$instance->requestId = $this->requestId;
		if ($this->responseCode === null) {
			throw new BuilderException('Property [responseCode] is required.');
		}
		$instance->responseCode = $this->responseCode;
		if ($this->responseHeaders === null) {
			throw new BuilderException('Property [responseHeaders] is required.');
		}
		$instance->responseHeaders = $this->responseHeaders;
		$instance->body = $this->body;
		$instance->responsePhrase = $this->responsePhrase;
		return $instance;
	}
297678
@Nullable
    protected final <T> T jsiiAsyncCall(final String method, final Class<T> returnType, @Nullable final Object... args) {
        JsiiClient client = engine.getClient();
        JsiiPromise promise = client.beginAsyncMethod(this.objRef, method, JsiiObjectMapper.valueToTree(args));

        engine.processAllPendingCallbacks();

        return JsiiObjectMapper.treeToValue(client.endAsyncMethod(promise), returnType);
    }
503652
public function start(): DriverInterface
    {
        if (!$this->process) {
            $this->process = (new ChromeProcess($this->port))->toProcess();
            $this->process->start();
            sleep(1);
        }

        return $this;
    }
572522
@Override
	public boolean satisfies(Match match, int... ind)
	{
		PhysicalEntity pe0 = (PhysicalEntity) match.get(ind[0]);
		PhysicalEntity pe1 = (PhysicalEntity) match.get(ind[1]);
		PhysicalEntity pe2 = (PhysicalEntity) match.get(ind[2]);
		PhysicalEntity pe3 = (PhysicalEntity) match.get(ind[3]);

		PhysicalEntityChain ch1 = new PhysicalEntityChain(pe0, pe1);
		PhysicalEntityChain ch2 = new PhysicalEntityChain(pe2, pe3);

		return ch1.intersects(ch2, ignoreEndPoints) == intersectionDesired;
	}
1203627
public static function implementsInterface($value, string $interface): bool
    {
        if (!is_object($value)) {
            if (!(static::classExists($value) || static::interfaceExists($value))) {
                return false;
            }
            $value = (string) $value;
        }

        $reflection = new ReflectionClass($value);

        return $reflection->implementsInterface($interface);
    }
292146
function satisfies(condition) {
    // Test with real version
    if (semver.satisfies(VERSION, condition)) return true;

    // Test with future stable release
    return semver.satisfies(VERSION_STABLE, condition);
}
1020051
public void satisfied (int condition)
    {
        // sanity check
        if (condition < 0 || condition >= _conditions.length) {
            throw new IllegalArgumentException(
                "Invalid condition supplied: " + condition + ". " +
                "Maximum is " + (_conditions.length-1) + ".");
        }

        // note that this condition was satisfied
        _conditions[condition] = true;

        // check to see if unsatisfied conditions remain
        for (int ii = 0; ii < _conditions.length; ii++) {
            if (!_conditions[ii]) {
                return;
            }
        }

        // reset ourselves and fire the action
        reset();
        _action.run();
    }
745830
private static Service<NetworkInterfaceBinding> createInterfaceService(String name, ParsedInterfaceCriteria criteria) {
        return NetworkInterfaceService.create(name, criteria);
    }
864404
public void registerService(Object service)
    {
    	this.setService(service);
    	String serviceClass = getInterfaceClassName(); 

    	if (service != null)
    		serviceRegistration = context.registerService(serviceClass, this.service, properties);
    }
821371
public function fulfill(): void
    {
        $this->state = Promise::FULFILLED;
        $response = $this->responseBuilder->getResponse();
        try {
            $response->getBody()->seek(0);
        } catch (\RuntimeException $e) {
            $exception = new Exception\TransferException($e->getMessage(), $e->getCode(), $e);
            $this->reject($exception);

            return;
        }

        while (count($this->onFulfilled) > 0) {
            $callback = array_shift($this->onFulfilled);
            $response = call_user_func($callback, $response);
        }

        if ($response instanceof ResponseInterface) {
            $this->responseBuilder->setResponse($response);
        }
    }