@param string $mode
@param mixed[] $cores

@return float[]
975925
private function convertPercentCoreValues($mode, array $cores)
	{
		$ncores = count($cores);

		if (strpos($cores[0], '%') !== false) {
			$cores[0] = (float) $cores[0];
			if ($mode === 'rgb' || $mode === 'rgba') {
				$cores[0] = (int) ($cores[0] * 255 / 100);
			}
		}

		if ($ncores > 1 && strpos($cores[1], '%') !== false) {
			$cores[1] = (float) $cores[1];
			if ($mode === 'rgb' || $mode === 'rgba') {
				$cores[1] = (int) ($cores[1] * 255 / 100);
			}
			if ($mode === 'hsl' || $mode === 'hsla') {
				$cores[1] /= 100;
			}
		}

		if ($ncores > 2 && strpos($cores[2], '%') !== false) {
			$cores[2] = (float) $cores[2];
			if ($mode === 'rgb' || $mode === 'rgba') {
				$cores[2] = (int) ($cores[2] * 255 / 100);
			}
			if ($mode === 'hsl' || $mode === 'hsla') {
				$cores[2] /= 100;
			}
		}

		if ($ncores > 3 && strpos($cores[3], '%') !== false) {
			$cores[3] = (float) $cores[3];
		}

		return $cores;
	}
311127
private function parseCollection(array $modes, $collection, &$root, $fullPropertyPath = '')
    {
        if (is_array($collection)) {
            foreach ($collection as $i => $resource) {
                $collection[$i] = $this->parseResource($modes, $resource, $root, $fullPropertyPath);
            }
        } elseif ($collection instanceof Collection) {
            $collection = $collection->map(function ($resource) use ($modes, &$root, $fullPropertyPath) {
                return $this->parseResource($modes, $resource, $root, $fullPropertyPath);
            });
        }

        return $collection;
    }
294264
public static function getCorePath($alias, $core){
		return self::normalizePath(self::combinePath(self::getAliasPath($alias), $core));
	}
1162644
public static function getTopics(Core $core, $limit = 100, $offset = 0) {
		$url = self::getTopicsUrl($core) . "?limit=" . $limit . "&offset=" . $offset; 

		$response = Client::GET($url, self::getHeaders($core));
		
		$body = self::getDataFromResponse($response);
		if (!property_exists($body, "topics")) {
			return null;
		}

		$topics = array();
		foreach ($body->{"topics"} as &$topic) {
			$topics[] = Topic::serializeFromJson($topic);
		}

		return $topics;
	}
756016
public static function compositeGUIDs($models)
    {
        if (empty($models)) {
            return null;
        }
        if (!is_array($models) && $models instanceof static) {
            return $models->getGUID();
        }
        if (is_string($models) && strlen($models) == 16) {
            return $models;
        }
        $guids = [];
        foreach ($models as $model) {
            if ($model instanceof static) {
                $guids[] = $model->getGUID();
            } elseif (is_string($model)) {
                if (strlen($model) == 16) {
                    $guids[] = $model;
                } elseif (preg_match(Number::GUID_REGEX, $model)) {
                    $guids[] = Number::guid_bin($model);
                }
            }
        }
        return $guids;
    }
565479
public function to_legacy_objects(array $forums) : array {
        return array_map(function(forum_entity $forum) {
            return (object) [
                'id' => $forum->get_id(),
                'course' => $forum->get_course_id(),
                'type' => $forum->get_type(),
                'name' => $forum->get_name(),
                'intro' => $forum->get_intro(),
                'introformat' => $forum->get_intro_format(),
                'assessed' => $forum->get_rating_aggregate(),
                'assesstimestart' => $forum->get_assess_time_start(),
                'assesstimefinish' => $forum->get_assess_time_finish(),
                'scale' => $forum->get_scale(),
                'maxbytes' => $forum->get_max_bytes(),
                'maxattachments' => $forum->get_max_attachments(),
                'forcesubscribe' => $forum->get_subscription_mode(),
                'trackingtype' => $forum->get_tracking_type(),
                'rsstype' => $forum->get_rss_type(),
                'rssarticles' => $forum->get_rss_articles(),
                'timemodified' => $forum->get_time_modified(),
                'warnafter' => $forum->get_warn_after(),
                'blockafter' => $forum->get_block_after(),
                'blockperiod' => $forum->get_block_period(),
                'completiondiscussions' => $forum->get_completion_discussions(),
                'completionreplies' => $forum->get_completion_replies(),
                'completionposts' => $forum->get_completion_posts(),
                'displaywordcount' => $forum->should_display_word_count(),
                'lockdiscussionafter' => $forum->get_lock_discussions_after(),
                'duedate' => $forum->get_due_date(),
                'cutoffdate' => $forum->get_cutoff_date()
            ];
        }, $forums);
    }
1092499
def _get_common_cores(resources):
    
    all_cores = []
    for vs in resources.values():
        cores = vs.get("cores")
        if cores:
            all_cores.append(int(vs["cores"]))
    return collections.Counter(all_cores).most_common(1)[0][0]
900816
private static function getPaddedBlock($bytesIn,$start,$end,$mode){
		if($end - $start > 16)
			$end = $start + 16;

		$xarray = array_slice($bytesIn, $start, $end-$start);

		$cpad = 16 - count($xarray);

		while(count($xarray) < 16){
			array_push($xarray, $cpad);
		}

		return $xarray;
	}
1241462
public static function getRsa($mode)
    {
        if (self::$rsa) {
            $rsa = self::$rsa;
        } else {
            $rsa = new RSA();
            $rsa->setMGFHash('sha256');
        }

        $rsa->setSignatureMode($mode);

        return $rsa;
    }
1130524
public function getCoreModules()
    {
        $coreModulesByName = $this->getCoreModulesByName();

        $coreModules = $this->all()->filter(
            function ($module) use ($coreModulesByName) {
                return array_key_exists($module->getLowerName(), $coreModulesByName->toArray());
            });

        return $coreModules->all();
    }
1113941
public static function getActions(\core_kernel_classes_Resource $module)
    {
        $returnValue = array();
        $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
        try {
            foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
                $uri = MapHelper::getUriForAction($controllerClassName, $actionName);
                $returnValue[$uri] = new \core_kernel_classes_Resource($uri);
            }
        } catch (\ReflectionException $e) {
            // unknown controller, no actions returned
        }
        return (array) $returnValue;
    }
150230
public function count($mode = COUNT_NORMAL)
    {
        if($mode == COUNT_RECURSIVE)
        {
            $count = 0;
            $data  = $this->__options;
            foreach ($data as $key => $value)
            {
                if(is_array($value) || $value instanceof ObjectConfig)
                {
                    if ($value instanceof ObjectConfigInterface) {
                        $count += $value->count($mode);
                    } else {
                        $count += count($value);
                    }
                }
            }
        }
        else $count = count($this->__options);

        return $count;
    }
796957
protected function _decrypt($values, $mode, $key = null)
    {
        if (is_string($values)) {
            return $this->_decode($values, $mode, $key);
        }

        $decrypted = [];
        foreach ($values as $name => $value) {
            $decrypted[$name] = $this->_decode($value, $mode, $key);
        }

        return $decrypted;
    }
481214
public function count($mode = COUNT_NORMAL)
    {
        if($mode == COUNT_RECURSIVE)
        {
            $count = 0;
            $data  = $this->__options;
            foreach ($data as $key => $value)
            {
                if(is_array($value) || $value instanceof KObjectConfig)
                {
                    if ($value instanceof KObjectConfigInterface) {
                        $count += $value->count($mode);
                    } else {
                        $count += count($value);
                    }
                }
            }
        }
        else $count = count($this->__options);

        return $count;
    }
1361643
public function get($mode = self::MODE_CURRENT_LEVEL) {

        $parameter = array();
        if ($mode === self::MODE_ALL_LEVELS) {
            $parameter['bubble'] = 'all';
        } else if ($mode === self::MODE_DISTINCT_NAMES) {
            $parameter['bubble'] = 'distinct';
        }
        $http = $this->send('GET', $parameter);
        if (!$http->ok) {
            $response = false;
        } else if ($this->simple) {
            $response = json_decode($http->response, true);
        } else if (isset($http->responseJson->{'@graph'})) {
            $response = array();
            foreach ($http->responseJson->{'@graph'} as $level) {
                $settings = json_decode(json_encode($level->custom), true);
                unset($settings['@id']);
                $response[self::$LEVEL_NAMES[$level->{'@type'}]] = $settings;
            }
        }

        return $response;

    }
909577
public function load($mode, $group, $namespace = null)
    {
        // Lets find where the paths are
        $paths = $this->getPaths($namespace);

        if (empty($paths)) return [];

        return $this->findInPaths($paths, $group, $mode);
    }
704271
public function coreComponents()
    {
        return ArrayHelper::merge(parent::coreComponents(), [
            'db' => [
                'class' => 'yii\db\Connection',
                'dsn' => getenv('DB_DSN'),
                'username' => getenv('DB_USER'),
                'password' => getenv('DB_PASSWORD'),
                'charset' => 'utf8',
                'tablePrefix' => getenv('DB_TABLE_PREFIX'),
                'enableSchemaCache' => YII_ENV_PROD ? true : false,
            ],
        ]);
    }