id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
40,700 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceUserEvaluationSerializer.php | ResourceUserEvaluationSerializer.serialize | public function serialize(ResourceUserEvaluation $resourceUserEvaluation)
{
$serialized = [
'id' => $resourceUserEvaluation->getId(),
'date' => $resourceUserEvaluation->getDate() ? $resourceUserEvaluation->getDate()->format('Y-m-d H:i') : null,
'status' => $resourceUserEvaluation->getStatus(),
'duration' => $resourceUserEvaluation->getDuration(),
'score' => $resourceUserEvaluation->getScore(),
'scoreMin' => $resourceUserEvaluation->getScoreMin(),
'scoreMax' => $resourceUserEvaluation->getScoreMax(),
'customScore' => $resourceUserEvaluation->getCustomScore(),
'progression' => $resourceUserEvaluation->getProgression(),
'resourceNode' => $this->resourceNodeSerializer->serialize($resourceUserEvaluation->getResourceNode()),
'user' => $this->userSerializer->serialize($resourceUserEvaluation->getUser()),
'userName' => $resourceUserEvaluation->getUserName(),
'nbAttempts' => $resourceUserEvaluation->getNbAttempts(),
'nbOpenings' => $resourceUserEvaluation->getNbOpenings(),
];
return $serialized;
} | php | public function serialize(ResourceUserEvaluation $resourceUserEvaluation)
{
$serialized = [
'id' => $resourceUserEvaluation->getId(),
'date' => $resourceUserEvaluation->getDate() ? $resourceUserEvaluation->getDate()->format('Y-m-d H:i') : null,
'status' => $resourceUserEvaluation->getStatus(),
'duration' => $resourceUserEvaluation->getDuration(),
'score' => $resourceUserEvaluation->getScore(),
'scoreMin' => $resourceUserEvaluation->getScoreMin(),
'scoreMax' => $resourceUserEvaluation->getScoreMax(),
'customScore' => $resourceUserEvaluation->getCustomScore(),
'progression' => $resourceUserEvaluation->getProgression(),
'resourceNode' => $this->resourceNodeSerializer->serialize($resourceUserEvaluation->getResourceNode()),
'user' => $this->userSerializer->serialize($resourceUserEvaluation->getUser()),
'userName' => $resourceUserEvaluation->getUserName(),
'nbAttempts' => $resourceUserEvaluation->getNbAttempts(),
'nbOpenings' => $resourceUserEvaluation->getNbOpenings(),
];
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"ResourceUserEvaluation",
"$",
"resourceUserEvaluation",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"resourceUserEvaluation",
"->",
"getId",
"(",
")",
",",
"'date'",
"=>",
"$",
"resourceUserEvaluation",
"->",
... | Serializes a ResourceUserEvaluation entity for the JSON api.
@param ResourceUserEvaluation $resourceUserEvaluation
@return array - the serialized representation of the resource evaluation | [
"Serializes",
"a",
"ResourceUserEvaluation",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceUserEvaluationSerializer.php#L42-L62 |
40,701 | claroline/Distribution | plugin/social-media/Listener/ApiListener.php | ApiListener.onSerialize | public function onSerialize(DecorateResourceNodeEvent $event)
{
$count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([
'resource' => $event->getResourceNode()->getId(),
]);
$event->add('social', [
'likes' => $count,
]);
} | php | public function onSerialize(DecorateResourceNodeEvent $event)
{
$count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([
'resource' => $event->getResourceNode()->getId(),
]);
$event->add('social', [
'likes' => $count,
]);
} | [
"public",
"function",
"onSerialize",
"(",
"DecorateResourceNodeEvent",
"$",
"event",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"om",
"->",
"getRepository",
"(",
"'IcapSocialmediaBundle:LikeAction'",
")",
"->",
"countLikes",
"(",
"[",
"'resource'",
"=>",
"$... | Add like count to serialized resource node when requested through API.
@DI\Observe("serialize_resource_node")
@param DecorateResourceNodeEvent $event | [
"Add",
"like",
"count",
"to",
"serialized",
"resource",
"node",
"when",
"requested",
"through",
"API",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/social-media/Listener/ApiListener.php#L40-L49 |
40,702 | claroline/Distribution | main/core/Entity/Widget/WidgetContainer.php | WidgetContainer.addInstance | public function addInstance(WidgetInstance $instance)
{
if (!$this->instances->contains($instance)) {
$this->instances->add($instance);
$instance->setContainer($this);
}
} | php | public function addInstance(WidgetInstance $instance)
{
if (!$this->instances->contains($instance)) {
$this->instances->add($instance);
$instance->setContainer($this);
}
} | [
"public",
"function",
"addInstance",
"(",
"WidgetInstance",
"$",
"instance",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"instances",
"->",
"contains",
"(",
"$",
"instance",
")",
")",
"{",
"$",
"this",
"->",
"instances",
"->",
"add",
"(",
"$",
"instan... | Add a WidgetInstance into the container.
@param WidgetInstance $instance | [
"Add",
"a",
"WidgetInstance",
"into",
"the",
"container",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Widget/WidgetContainer.php#L82-L88 |
40,703 | claroline/Distribution | main/core/Entity/Widget/WidgetContainer.php | WidgetContainer.removeInstance | public function removeInstance(WidgetInstance $instance)
{
if ($this->instances->contains($instance)) {
$this->instances->removeElement($instance);
}
} | php | public function removeInstance(WidgetInstance $instance)
{
if ($this->instances->contains($instance)) {
$this->instances->removeElement($instance);
}
} | [
"public",
"function",
"removeInstance",
"(",
"WidgetInstance",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"instances",
"->",
"contains",
"(",
"$",
"instance",
")",
")",
"{",
"$",
"this",
"->",
"instances",
"->",
"removeElement",
"(",
"$",
"... | Remove a WidgetInstance from the container.
@param WidgetInstance $instance | [
"Remove",
"a",
"WidgetInstance",
"from",
"the",
"container",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Widget/WidgetContainer.php#L95-L100 |
40,704 | claroline/Distribution | main/core/Controller/APINew/Model/HasOrganizationsTrait.php | HasOrganizationsTrait.addOrganizationsAction | public function addOrganizationsAction($id, $class, Request $request)
{
$object = $this->find($class, $id);
$organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization');
$this->crud->patch($object, 'organization', Crud::COLLECTION_ADD, $organizations);
return new JsonResponse(
$this->serializer->serialize($object)
);
} | php | public function addOrganizationsAction($id, $class, Request $request)
{
$object = $this->find($class, $id);
$organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization');
$this->crud->patch($object, 'organization', Crud::COLLECTION_ADD, $organizations);
return new JsonResponse(
$this->serializer->serialize($object)
);
} | [
"public",
"function",
"addOrganizationsAction",
"(",
"$",
"id",
",",
"$",
"class",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"class",
",",
"$",
"id",
")",
";",
"$",
"organizations",
"=",
"$",
... | Adds organizations to the collection.
@EXT\Route("/{id}/organization")
@EXT\Method("PATCH")
@param string $id
@param string $class
@param Request $request
@return JsonResponse | [
"Adds",
"organizations",
"to",
"the",
"collection",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasOrganizationsTrait.php#L49-L58 |
40,705 | claroline/Distribution | main/core/Controller/APINew/Model/HasOrganizationsTrait.php | HasOrganizationsTrait.removeOrganizationsAction | public function removeOrganizationsAction($id, $class, Request $request)
{
$object = $this->find($class, $id);
$organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization');
$this->crud->patch($object, 'organization', Crud::COLLECTION_REMOVE, $organizations);
return new JsonResponse(
$this->serializer->serialize($object)
);
} | php | public function removeOrganizationsAction($id, $class, Request $request)
{
$object = $this->find($class, $id);
$organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization');
$this->crud->patch($object, 'organization', Crud::COLLECTION_REMOVE, $organizations);
return new JsonResponse(
$this->serializer->serialize($object)
);
} | [
"public",
"function",
"removeOrganizationsAction",
"(",
"$",
"id",
",",
"$",
"class",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"class",
",",
"$",
"id",
")",
";",
"$",
"organizations",
"=",
"$"... | Removes organizations from the collection.
@EXT\Route("/{id}/organization")
@EXT\Method("DELETE")
@param string $id
@param string $class
@param Request $request
@return JsonResponse | [
"Removes",
"organizations",
"from",
"the",
"collection",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasOrganizationsTrait.php#L72-L81 |
40,706 | claroline/Distribution | plugin/exo/Library/Model/AttemptParametersTrait.php | AttemptParametersTrait.setMaxAttemptsPerDay | public function setMaxAttemptsPerDay($maxAttemptsPerDay)
{
if ($maxAttemptsPerDay > $this->maxAttempts) {
//we can't try more times per day than the maximum allowed attempts defined
$this->maxAttemptsPerDay = $this->maxAttempts;
}
$this->maxAttemptsPerDay = $maxAttemptsPerDay;
} | php | public function setMaxAttemptsPerDay($maxAttemptsPerDay)
{
if ($maxAttemptsPerDay > $this->maxAttempts) {
//we can't try more times per day than the maximum allowed attempts defined
$this->maxAttemptsPerDay = $this->maxAttempts;
}
$this->maxAttemptsPerDay = $maxAttemptsPerDay;
} | [
"public",
"function",
"setMaxAttemptsPerDay",
"(",
"$",
"maxAttemptsPerDay",
")",
"{",
"if",
"(",
"$",
"maxAttemptsPerDay",
">",
"$",
"this",
"->",
"maxAttempts",
")",
"{",
"//we can't try more times per day than the maximum allowed attempts defined",
"$",
"this",
"->",
... | Sets max attempts.
@param int $maxAttemptsPerDay | [
"Sets",
"max",
"attempts",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Model/AttemptParametersTrait.php#L179-L187 |
40,707 | claroline/Distribution | plugin/tag/Controller/TagController.php | TagController.listObjectsAction | public function listObjectsAction(Tag $tag, Request $request)
{
return new JsonResponse(
$this->finder->search(TaggedObject::class, array_merge(
$request->query->all(),
['hiddenFilters' => [$this->getName() => $tag->getUuid()]]
))
);
} | php | public function listObjectsAction(Tag $tag, Request $request)
{
return new JsonResponse(
$this->finder->search(TaggedObject::class, array_merge(
$request->query->all(),
['hiddenFilters' => [$this->getName() => $tag->getUuid()]]
))
);
} | [
"public",
"function",
"listObjectsAction",
"(",
"Tag",
"$",
"tag",
",",
"Request",
"$",
"request",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"$",
"this",
"->",
"finder",
"->",
"search",
"(",
"TaggedObject",
"::",
"class",
",",
"array_merge",
"(",
"$"... | List all objects linked to a Tag.
@EXT\Route("/{id}/object", name="apiv2_tag_list_objects")
@EXT\ParamConverter("tag", class="ClarolineTagBundle:Tag", options={"mapping": {"id": "uuid"}})
@EXT\Method("GET")
@param Tag $tag
@param Request $request
@return JsonResponse | [
"List",
"all",
"objects",
"linked",
"to",
"a",
"Tag",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Controller/TagController.php#L69-L77 |
40,708 | claroline/Distribution | plugin/tag/Controller/TagController.php | TagController.addObjectsAction | public function addObjectsAction($tag, User $user, Request $request)
{
$taggedObjects = $this->manager->tagData([$tag], $this->decodeRequest($request), $user);
return new JsonResponse(
!empty($taggedObjects) ? $this->serializer->serialize($taggedObjects[0]->getTag()) : null
);
} | php | public function addObjectsAction($tag, User $user, Request $request)
{
$taggedObjects = $this->manager->tagData([$tag], $this->decodeRequest($request), $user);
return new JsonResponse(
!empty($taggedObjects) ? $this->serializer->serialize($taggedObjects[0]->getTag()) : null
);
} | [
"public",
"function",
"addObjectsAction",
"(",
"$",
"tag",
",",
"User",
"$",
"user",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"taggedObjects",
"=",
"$",
"this",
"->",
"manager",
"->",
"tagData",
"(",
"[",
"$",
"tag",
"]",
",",
"$",
"this",
"->"... | Adds a tag to a collection of taggable objects.
NB. If the tag does not exist, it will be created.
@EXT\Route("/{tag}/object", name="apiv2_tag_add_objects")
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@EXT\Method("POST")
@param string $tag
@param User $user
@param Request $request
@return JsonResponse | [
"Adds",
"a",
"tag",
"to",
"a",
"collection",
"of",
"taggable",
"objects",
".",
"NB",
".",
"If",
"the",
"tag",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Controller/TagController.php#L93-L100 |
40,709 | claroline/Distribution | main/app/Manager/CacheManager.php | CacheManager.getParameter | public function getParameter($parameter)
{
$isRefreshed = false;
if (!$this->cacheExists()) {
$this->refresh();
$isRefreshed = true;
}
$values = parse_ini_file($this->cachePath);
$return = null;
if (isset($values[$parameter])) {
$return = $values[$parameter];
} else {
if (!$isRefreshed) {
$this->refresh();
$values = parse_ini_file($this->cachePath);
if (isset($values[$parameter])) {
$return = $values[$parameter];
}
}
}
return $return ? $return : false;
} | php | public function getParameter($parameter)
{
$isRefreshed = false;
if (!$this->cacheExists()) {
$this->refresh();
$isRefreshed = true;
}
$values = parse_ini_file($this->cachePath);
$return = null;
if (isset($values[$parameter])) {
$return = $values[$parameter];
} else {
if (!$isRefreshed) {
$this->refresh();
$values = parse_ini_file($this->cachePath);
if (isset($values[$parameter])) {
$return = $values[$parameter];
}
}
}
return $return ? $return : false;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"parameter",
")",
"{",
"$",
"isRefreshed",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"$",
"isRefreshed",
"=",
... | Read a value from the claroline cache.
@param $parameter
@throws \Exception
@return mixed | [
"Read",
"a",
"value",
"from",
"the",
"claroline",
"cache",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Manager/CacheManager.php#L59-L85 |
40,710 | claroline/Distribution | main/app/Manager/CacheManager.php | CacheManager.refresh | public function refresh()
{
$this->removeCache();
/** @var RefreshCacheEvent $event */
$event = $this->eventDispatcher->dispatch('refresh_cache', RefreshCacheEvent::class);
$this->writeCache($event->getParameters());
} | php | public function refresh()
{
$this->removeCache();
/** @var RefreshCacheEvent $event */
$event = $this->eventDispatcher->dispatch('refresh_cache', RefreshCacheEvent::class);
$this->writeCache($event->getParameters());
} | [
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"this",
"->",
"removeCache",
"(",
")",
";",
"/** @var RefreshCacheEvent $event */",
"$",
"event",
"=",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"'refresh_cache'",
",",
"RefreshCacheEvent",
... | Refresh the claroline cache. | [
"Refresh",
"the",
"claroline",
"cache",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Manager/CacheManager.php#L102-L110 |
40,711 | claroline/Distribution | plugin/reservation/Serializer/ResourceRightsSerializer.php | ResourceRightsSerializer.deserialize | public function deserialize($data, ResourceRights $resourceRights = null)
{
if (empty($resourceRights)) {
$resourceRights = new ResourceRights();
}
if (isset($data['mask'])) {
$resourceRights->setMask($data['mask']);
}
if (isset($data['resource'])) {
$resource = $this->resourceRepo->findOneBy(['uuid' => $data['resource']['id']]);
$resourceRights->setResource($resource);
}
if (isset($data['role'])) {
$role = $this->roleRepo->findOneBy(['uuid' => $data['role']['id']]);
$resourceRights->setRole($role);
}
return $resourceRights;
} | php | public function deserialize($data, ResourceRights $resourceRights = null)
{
if (empty($resourceRights)) {
$resourceRights = new ResourceRights();
}
if (isset($data['mask'])) {
$resourceRights->setMask($data['mask']);
}
if (isset($data['resource'])) {
$resource = $this->resourceRepo->findOneBy(['uuid' => $data['resource']['id']]);
$resourceRights->setResource($resource);
}
if (isset($data['role'])) {
$role = $this->roleRepo->findOneBy(['uuid' => $data['role']['id']]);
$resourceRights->setRole($role);
}
return $resourceRights;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"ResourceRights",
"$",
"resourceRights",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"resourceRights",
")",
")",
"{",
"$",
"resourceRights",
"=",
"new",
"ResourceRights",
"(",
")",
";",
... | Deserializes data into a ResourceRights entity.
@param \stdClass $data
@param ResourceRights $resourceRights
@return ResourceRights | [
"Deserializes",
"data",
"into",
"a",
"ResourceRights",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Serializer/ResourceRightsSerializer.php#L67-L85 |
40,712 | claroline/Distribution | main/core/Listener/AuthenticationSuccessListener.php | AuthenticationSuccessListener.checkTermOfServices | public function checkTermOfServices(GetResponseEvent $event)
{
if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) {
$user = !empty($this->tokenStorage->getToken()) ? $this->tokenStorage->getToken()->getUser() : null;
if ($user instanceof User && $this->configurationHandler->getParameter('terms_of_service')) {
$this->showTermOfServices($event);
}
}
} | php | public function checkTermOfServices(GetResponseEvent $event)
{
if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) {
$user = !empty($this->tokenStorage->getToken()) ? $this->tokenStorage->getToken()->getUser() : null;
if ($user instanceof User && $this->configurationHandler->getParameter('terms_of_service')) {
$this->showTermOfServices($event);
}
}
} | [
"public",
"function",
"checkTermOfServices",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"'prod'",
"===",
"$",
"this",
"->",
"kernel",
"->",
"getEnvironment",
"(",
")",
"&&",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"$",
... | Checks the current user has accepted term of services if any before displaying platform.
@DI\Observe("kernel.request")
@param GetResponseEvent $event | [
"Checks",
"the",
"current",
"user",
"has",
"accepted",
"term",
"of",
"services",
"if",
"any",
"before",
"displaying",
"platform",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/AuthenticationSuccessListener.php#L229-L237 |
40,713 | claroline/Distribution | main/core/Listener/AuthenticationSuccessListener.php | AuthenticationSuccessListener.getUser | private function getUser(Request $request)
{
if ($this->configurationHandler->getParameter('terms_of_service')
&& 'claroline_locale_change' !== $request->get('_route')
&& 'claroline_locale_select' !== $request->get('_route')
&& 'bazinga_exposetranslation_js' !== $request->get('_route')
&& ($token = $this->tokenStorage->getToken())
&& ($user = $token->getUser())
&& $user instanceof User
) {
return $user;
}
return null;
} | php | private function getUser(Request $request)
{
if ($this->configurationHandler->getParameter('terms_of_service')
&& 'claroline_locale_change' !== $request->get('_route')
&& 'claroline_locale_select' !== $request->get('_route')
&& 'bazinga_exposetranslation_js' !== $request->get('_route')
&& ($token = $this->tokenStorage->getToken())
&& ($user = $token->getUser())
&& $user instanceof User
) {
return $user;
}
return null;
} | [
"private",
"function",
"getUser",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configurationHandler",
"->",
"getParameter",
"(",
"'terms_of_service'",
")",
"&&",
"'claroline_locale_change'",
"!==",
"$",
"request",
"->",
"get",
"(",
... | Return a user if need to accept the terms of service.
@param \Symfony\Component\HttpFoundation\Request $request
@return User | [
"Return",
"a",
"user",
"if",
"need",
"to",
"accept",
"the",
"terms",
"of",
"service",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/AuthenticationSuccessListener.php#L309-L323 |
40,714 | fastdlabs/http | src/Response.php | Response.withExpires | public function withExpires(DateTime $date)
{
$timezone = new DateTimeZone("PRC");
$this->withoutHeader('Expires');
$date->setTimezone($timezone);
$this->withHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT');
$maxAge = $date->getTimestamp() - (new DateTime('now', $timezone))->getTimestamp();
$this->withMaxAge($maxAge);
return $this;
} | php | public function withExpires(DateTime $date)
{
$timezone = new DateTimeZone("PRC");
$this->withoutHeader('Expires');
$date->setTimezone($timezone);
$this->withHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT');
$maxAge = $date->getTimestamp() - (new DateTime('now', $timezone))->getTimestamp();
$this->withMaxAge($maxAge);
return $this;
} | [
"public",
"function",
"withExpires",
"(",
"DateTime",
"$",
"date",
")",
"{",
"$",
"timezone",
"=",
"new",
"DateTimeZone",
"(",
"\"PRC\"",
")",
";",
"$",
"this",
"->",
"withoutHeader",
"(",
"'Expires'",
")",
";",
"$",
"date",
"->",
"setTimezone",
"(",
"$"... | Sets the Expires HTTP header with a DateTime instance.
Passing null as value will remove the header.
@param DateTime|null $date A \DateTime instance or null to remove the header
@return $this | [
"Sets",
"the",
"Expires",
"HTTP",
"header",
"with",
"a",
"DateTime",
"instance",
"."
] | 9ac973b4eaefb9b7f28ff7550077643f4128ef99 | https://github.com/fastdlabs/http/blob/9ac973b4eaefb9b7f28ff7550077643f4128ef99/src/Response.php#L448-L460 |
40,715 | fastdlabs/http | src/Response.php | Response.withNotModified | public function withNotModified()
{
$this->withStatus(static::HTTP_NOT_MODIFIED);
$this->getBody()->write('');
// remove headers that MUST NOT be included with 304 Not Modified responses
foreach ([
'Allow',
'Content-Encoding',
'Content-Language',
'Content-Length',
'Content-MD5',
'Content-Type',
'Last-Modified'] as $header) {
$this->withoutHeader($header);
}
return $this;
} | php | public function withNotModified()
{
$this->withStatus(static::HTTP_NOT_MODIFIED);
$this->getBody()->write('');
// remove headers that MUST NOT be included with 304 Not Modified responses
foreach ([
'Allow',
'Content-Encoding',
'Content-Language',
'Content-Length',
'Content-MD5',
'Content-Type',
'Last-Modified'] as $header) {
$this->withoutHeader($header);
}
return $this;
} | [
"public",
"function",
"withNotModified",
"(",
")",
"{",
"$",
"this",
"->",
"withStatus",
"(",
"static",
"::",
"HTTP_NOT_MODIFIED",
")",
";",
"$",
"this",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"''",
")",
";",
"// remove headers that MUST NOT be include... | Modifies the response so that it conforms to the rules defined for a 304 status code.
This sets the status, removes the body, and discards any headers
that MUST NOT be included in 304 responses.
@return Response
@see http://tools.ietf.org/html/rfc2616#section-10.3.5 | [
"Modifies",
"the",
"response",
"so",
"that",
"it",
"conforms",
"to",
"the",
"rules",
"defined",
"for",
"a",
"304",
"status",
"code",
"."
] | 9ac973b4eaefb9b7f28ff7550077643f4128ef99 | https://github.com/fastdlabs/http/blob/9ac973b4eaefb9b7f28ff7550077643f4128ef99/src/Response.php#L550-L568 |
40,716 | krizalys/onedrive-php-sdk | src/Folder.php | Folder.fetchDriveItems | public function fetchDriveItems()
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
return array_map(function (DriveItemProxy $item) use ($client) {
$options = $client->buildOptions($item, ['parent_id' => $this->_id]);
return $client->isFolder($item) ?
new self($client, $item->id, $options)
: new File($client, $item->id, $options);
}, $item->children);
} | php | public function fetchDriveItems()
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
return array_map(function (DriveItemProxy $item) use ($client) {
$options = $client->buildOptions($item, ['parent_id' => $this->_id]);
return $client->isFolder($item) ?
new self($client, $item->id, $options)
: new File($client, $item->id, $options);
}, $item->children);
} | [
"public",
"function",
"fetchDriveItems",
"(",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"_client",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Proxy\\DriveItemProxy::children'",
... | Gets the drive items in the OneDrive folder referenced by this Folder
instance.
@return array
The drive items in the OneDrive folder referenced by this Folder
instance, as DriveItem instances.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::children instead. | [
"Gets",
"the",
"drive",
"items",
"in",
"the",
"OneDrive",
"folder",
"referenced",
"by",
"this",
"Folder",
"instance",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L53-L75 |
40,717 | krizalys/onedrive-php-sdk | src/Folder.php | Folder.createFolder | public function createFolder($name, $description = null)
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->createFolder($name, $options);
$options = $client->buildOptions($item, ['parent_id' => $parentId]);
return new self($client, $item->id, $options);
} | php | public function createFolder($name, $description = null)
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->createFolder($name, $options);
$options = $client->buildOptions($item, ['parent_id' => $parentId]);
return new self($client, $item->id, $options);
} | [
"public",
"function",
"createFolder",
"(",
"$",
"name",
",",
"$",
"description",
"=",
"null",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"_client",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"... | Creates a folder in the OneDrive folder referenced by this Folder
instance.
@param string $name
The name of the OneDrive folder to be created.
@param null|string $description
The description of the OneDrive folder to be created, or null to
create it without a description. Default: null.
@return Folder
The folder created, as a Folder instance.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()
instead. | [
"Creates",
"a",
"folder",
"in",
"the",
"OneDrive",
"folder",
"referenced",
"by",
"this",
"Folder",
"instance",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L127-L153 |
40,718 | krizalys/onedrive-php-sdk | src/Folder.php | Folder.createFile | public function createFile($name, $content = '', array $options = [])
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->upload($name, $content, $options);
$options = $client->buildOptions($item, ['parent_id' => $parentId]);
return new File($client, $item->id, $options);
} | php | public function createFile($name, $content = '', array $options = [])
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->upload($name, $content, $options);
$options = $client->buildOptions($item, ['parent_id' => $parentId]);
return new File($client, $item->id, $options);
} | [
"public",
"function",
"createFile",
"(",
"$",
"name",
",",
"$",
"content",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"_client",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is depreca... | Creates a file in the OneDrive folder referenced by this Folder instance.
@param string $name
The name of the OneDrive file to be created.
@param string|resource $content
The content of the OneDrive file to be created, as a string or
handle to an already opened file. In the latter case, the
responsibility to close the handle is is left to the calling
function. Default: ''.
@param array $options
The options.
@return File
The file created, as a File instance.
@throws Exception
Thrown on I/O errors.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::upload() instead. | [
"Creates",
"a",
"file",
"in",
"the",
"OneDrive",
"folder",
"referenced",
"by",
"this",
"Folder",
"instance",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L176-L202 |
40,719 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.getChildren | public function getChildren()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/children";
$response = $this
->graph
->createCollectionRequest('GET', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status");
}
$driveItems = $response->getResponseAsObject(DriveItem::class);
if (!is_array($driveItems)) {
return [];
}
return array_map(function (DriveItem $driveItem) {
return new self($this->graph, $driveItem);
}, $driveItems);
} | php | public function getChildren()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/children";
$response = $this
->graph
->createCollectionRequest('GET', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status");
}
$driveItems = $response->getResponseAsObject(DriveItem::class);
if (!is_array($driveItems)) {
return [];
}
return array_map(function (DriveItem $driveItem) {
return new self($this->graph, $driveItem);
}, $driveItems);
} | [
"public",
"function",
"getChildren",
"(",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
"endpoint",
"=",
"\"$driveLocator$itemLocator/children\"",
";",
"$",
"response"... | Gets this folder drive item's children.
@return array
The child drive items.
@todo Support pagination using a native iterator. | [
"Gets",
"this",
"folder",
"drive",
"item",
"s",
"children",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L211-L237 |
40,720 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.delete | public function delete()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$response = $this
->graph
->createRequest('DELETE', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 204) {
throw new \Exception("Unexpected status code produced by 'DELETE $endpoint': $status");
}
} | php | public function delete()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$response = $this
->graph
->createRequest('DELETE', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 204) {
throw new \Exception("Unexpected status code produced by 'DELETE $endpoint': $status");
}
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
"endpoint",
"=",
"\"$driveLocator$itemLocator\"",
";",
"$",
"response",
"=",
"$"... | Deletes this drive item. | [
"Deletes",
"this",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L242-L258 |
40,721 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.upload | public function upload($name, $content, array $options = [])
{
$name = rawurlencode($name);
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator:/$name:/content";
$body = $content instanceof Stream ?
$content
: Psr7\stream_for($content);
$response = $this
->graph
->createRequest('PUT', $endpoint)
->addHeaders($options)
->attachBody($body)
->execute();
$status = $response->getStatus();
if ($status != 200 && $status != 201) {
throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | php | public function upload($name, $content, array $options = [])
{
$name = rawurlencode($name);
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator:/$name:/content";
$body = $content instanceof Stream ?
$content
: Psr7\stream_for($content);
$response = $this
->graph
->createRequest('PUT', $endpoint)
->addHeaders($options)
->attachBody($body)
->execute();
$status = $response->getStatus();
if ($status != 200 && $status != 201) {
throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | [
"public",
"function",
"upload",
"(",
"$",
"name",
",",
"$",
"content",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"rawurlencode",
"(",
"$",
"name",
")",
";",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveI... | Uploads a file under this folder drive item.
@param string $name
The name.
@param string|resource|\GuzzleHttp\Psr7\Stream $content
The content.
@param array $options
The options.
@return DriveItemProxy
The drive item created.
@todo Support name conflict behavior.
@todo Support content type in options. | [
"Uploads",
"a",
"file",
"under",
"this",
"folder",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L276-L303 |
40,722 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.startUpload | public function startUpload($name, $content, array $options = [])
{
$name = rawurlencode($name);
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator:/$name:/createUploadSession";
$response = $this
->graph
->createRequest('POST', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status");
}
$uploadSession = $response->getResponseAsObject(UploadSession::class);
return new UploadSessionProxy($this->graph, $uploadSession, $content, $options);
} | php | public function startUpload($name, $content, array $options = [])
{
$name = rawurlencode($name);
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator:/$name:/createUploadSession";
$response = $this
->graph
->createRequest('POST', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status");
}
$uploadSession = $response->getResponseAsObject(UploadSession::class);
return new UploadSessionProxy($this->graph, $uploadSession, $content, $options);
} | [
"public",
"function",
"startUpload",
"(",
"$",
"name",
",",
"$",
"content",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"rawurlencode",
"(",
"$",
"name",
")",
";",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->d... | Creates an upload session to upload a large file in multiple ranges under
this folder drive item.
@param string $name
The name.
@param string|resource|\GuzzleHttp\Psr7\Stream $content
The content.
@param array $options
The options.
@return UploadSessionProxy
The upload session created.
@todo Support name conflict behavior.
@todo Support content type in options. | [
"Creates",
"an",
"upload",
"session",
"to",
"upload",
"a",
"large",
"file",
"in",
"multiple",
"ranges",
"under",
"this",
"folder",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L322-L343 |
40,723 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.download | public function download()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/content";
$response = $this
->graph
->createRequest('GET', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status");
}
return $response->getResponseAsObject(Stream::class);
} | php | public function download()
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/content";
$response = $this
->graph
->createRequest('GET', $endpoint)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status");
}
return $response->getResponseAsObject(Stream::class);
} | [
"public",
"function",
"download",
"(",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
"endpoint",
"=",
"\"$driveLocator$itemLocator/content\"",
";",
"$",
"response",
... | Downloads this file drive item.
@return GuzzleHttp\Psr7\Stream
The content. | [
"Downloads",
"this",
"file",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L351-L369 |
40,724 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.rename | public function rename($name, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$body = [
'name' => (string) $name,
];
$response = $this
->graph
->createRequest('PATCH', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | php | public function rename($name, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$body = [
'name' => (string) $name,
];
$response = $this
->graph
->createRequest('PATCH', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | [
"public",
"function",
"rename",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
"endpoint",
"=",... | Renames this file item.
@param string $name
The name.
@param array $options
The options.
@return DriveItemProxy
The drive item renamed. | [
"Renames",
"this",
"file",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L382-L407 |
40,725 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.move | public function move(self $destinationItem, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$body = [
'parentReference' => [
'id' => $destinationItem->id,
],
];
$response = $this
->graph
->createRequest('PATCH', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | php | public function move(self $destinationItem, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator";
$body = [
'parentReference' => [
'id' => $destinationItem->id,
],
];
$response = $this
->graph
->createRequest('PATCH', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 200) {
throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status");
}
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new self($this->graph, $driveItem);
} | [
"public",
"function",
"move",
"(",
"self",
"$",
"destinationItem",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
... | Moves this drive item.
@param DriveItemProxy $destinationItem
The destination item.
@param array $options
The options.
@return DriveItemProxy
The drive item. | [
"Moves",
"this",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L420-L447 |
40,726 | krizalys/onedrive-php-sdk | src/Proxy/DriveItemProxy.php | DriveItemProxy.copy | public function copy(self $destinationItem, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/copy";
$body = [
'parentReference' => [
'id' => $destinationItem->id,
],
];
$response = $this
->graph
->createRequest('POST', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 202) {
throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status");
}
$headers = $response->getHeaders();
return $headers['Location'][0];
} | php | public function copy(self $destinationItem, array $options = [])
{
$driveLocator = "/drives/{$this->parentReference->driveId}";
$itemLocator = "/items/{$this->id}";
$endpoint = "$driveLocator$itemLocator/copy";
$body = [
'parentReference' => [
'id' => $destinationItem->id,
],
];
$response = $this
->graph
->createRequest('POST', $endpoint)
->attachBody($body + $options)
->execute();
$status = $response->getStatus();
if ($status != 202) {
throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status");
}
$headers = $response->getHeaders();
return $headers['Location'][0];
} | [
"public",
"function",
"copy",
"(",
"self",
"$",
"destinationItem",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"driveLocator",
"=",
"\"/drives/{$this->parentReference->driveId}\"",
";",
"$",
"itemLocator",
"=",
"\"/items/{$this->id}\"",
";",
"$",
... | Copies this drive item.
@param DriveItemProxy $destinationItem
The destination item.
@param array $options
The options.
@return string
The progress URI.
@todo Support asynchronous Graph operation. | [
"Copies",
"this",
"drive",
"item",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L462-L489 |
40,727 | krizalys/onedrive-php-sdk | src/DriveItem.php | DriveItem.fetchProperties | public function fetchProperties()
{
$result = $this->_client->fetchProperties($this->_id);
$this->_parentId = '' != $result->parent_id ?
(string) $result->parent_id : null;
$this->_name = $result->name;
$this->_description = '' != $result->description ?
(string) $result->description : null;
$this->_size = (int) $result->size;
/** @todo Handle volatile existence (eg. present only for files). */
$this->_source = (string) $result->source;
$this->_createdTime = strtotime($result->created_time);
$this->_updatedTime = strtotime($result->updated_time);
return $result;
} | php | public function fetchProperties()
{
$result = $this->_client->fetchProperties($this->_id);
$this->_parentId = '' != $result->parent_id ?
(string) $result->parent_id : null;
$this->_name = $result->name;
$this->_description = '' != $result->description ?
(string) $result->description : null;
$this->_size = (int) $result->size;
/** @todo Handle volatile existence (eg. present only for files). */
$this->_source = (string) $result->source;
$this->_createdTime = strtotime($result->created_time);
$this->_updatedTime = strtotime($result->updated_time);
return $result;
} | [
"public",
"function",
"fetchProperties",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_client",
"->",
"fetchProperties",
"(",
"$",
"this",
"->",
"_id",
")",
";",
"$",
"this",
"->",
"_parentId",
"=",
"''",
"!=",
"$",
"result",
"->",
"parent_id... | Fetches the properties of the OneDrive drive item referenced by this
DriveItem instance. Some properties are cached for faster subsequent
access.
@return array
The properties of the OneDrive drive item referenced by this
DriveItem instance. | [
"Fetches",
"the",
"properties",
"of",
"the",
"OneDrive",
"drive",
"item",
"referenced",
"by",
"this",
"DriveItem",
"instance",
".",
"Some",
"properties",
"are",
"cached",
"for",
"faster",
"subsequent",
"access",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/DriveItem.php#L151-L172 |
40,728 | krizalys/onedrive-php-sdk | src/DriveItem.php | DriveItem.move | public function move($destinationId = null)
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$destinationItem = $client->getDriveItemById($drive->id, $destinationId);
return $item->move($destinationItem);
} | php | public function move($destinationId = null)
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
$destinationItem = $client->getDriveItemById($drive->id, $destinationId);
return $item->move($destinationItem);
} | [
"public",
"function",
"move",
"(",
"$",
"destinationId",
"=",
"null",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"_client",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Prox... | Moves the OneDrive drive item referenced by this DriveItem instance into
another OneDrive folder.
@param null|string $destinationId
The unique ID of the OneDrive folder into which to move the
OneDrive drive item referenced by this DriveItem instance, or null
to move it to the OneDrive root folder. Default: null.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::move() instead. | [
"Moves",
"the",
"OneDrive",
"drive",
"item",
"referenced",
"by",
"this",
"DriveItem",
"instance",
"into",
"another",
"OneDrive",
"folder",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/DriveItem.php#L317-L334 |
40,729 | krizalys/onedrive-php-sdk | src/Proxy/UploadSessionProxy.php | UploadSessionProxy.complete | public function complete()
{
$stream = $this->content instanceof Stream ?
$this->content
: Psr7\stream_for($this->content);
if ($this->rangeSize !== null) {
$rangeSize = $this->rangeSize;
$rangeSize = $rangeSize - $rangeSize % self::RANGE_SIZE_MULTIPLE;
$rangeSize = min($rangeSize, self::MAX_RANGE_SIZE);
$rangeSize = max($rangeSize, self::MIN_RANGE_SIZE);
} else {
$rangeSize = self::RANGE_SIZE_MULTIPLE;
}
$size = $stream->getSize();
$offset = 0;
while (!$stream->eof()) {
$rangeStream = new LimitStream($stream, $rangeSize, $offset);
$rangeSize = $rangeStream->getSize();
$body = $rangeStream->getContents();
$rangeFirst = $offset;
$offset += $rangeSize;
$rangeLast = $offset - 1;
$headers = [
'Content-Length' => $rangeSize,
'Content-Range' => "bytes $rangeFirst-$rangeLast/$size",
];
if ($this->type !== null) {
$headers['Content-Type'] = $this->type;
}
$response = $this
->graph
->createRequest('PUT', $this->uploadUrl)
->addHeaders($headers)
->attachBody($body)
->execute();
$status = $response->getStatus();
if ($status == 200 || $status == 201) {
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new DriveItemProxy($this->graph, $driveItem);
}
if ($status != 202) {
throw new \Exception("Unexpected status code produced by 'PUT {$this->uploadUrl}': $status");
}
}
throw new \Exception('OneDrive did not create a drive item for the uploaded file');
} | php | public function complete()
{
$stream = $this->content instanceof Stream ?
$this->content
: Psr7\stream_for($this->content);
if ($this->rangeSize !== null) {
$rangeSize = $this->rangeSize;
$rangeSize = $rangeSize - $rangeSize % self::RANGE_SIZE_MULTIPLE;
$rangeSize = min($rangeSize, self::MAX_RANGE_SIZE);
$rangeSize = max($rangeSize, self::MIN_RANGE_SIZE);
} else {
$rangeSize = self::RANGE_SIZE_MULTIPLE;
}
$size = $stream->getSize();
$offset = 0;
while (!$stream->eof()) {
$rangeStream = new LimitStream($stream, $rangeSize, $offset);
$rangeSize = $rangeStream->getSize();
$body = $rangeStream->getContents();
$rangeFirst = $offset;
$offset += $rangeSize;
$rangeLast = $offset - 1;
$headers = [
'Content-Length' => $rangeSize,
'Content-Range' => "bytes $rangeFirst-$rangeLast/$size",
];
if ($this->type !== null) {
$headers['Content-Type'] = $this->type;
}
$response = $this
->graph
->createRequest('PUT', $this->uploadUrl)
->addHeaders($headers)
->attachBody($body)
->execute();
$status = $response->getStatus();
if ($status == 200 || $status == 201) {
$driveItem = $response->getResponseAsObject(DriveItem::class);
return new DriveItemProxy($this->graph, $driveItem);
}
if ($status != 202) {
throw new \Exception("Unexpected status code produced by 'PUT {$this->uploadUrl}': $status");
}
}
throw new \Exception('OneDrive did not create a drive item for the uploaded file');
} | [
"public",
"function",
"complete",
"(",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"content",
"instanceof",
"Stream",
"?",
"$",
"this",
"->",
"content",
":",
"Psr7",
"\\",
"stream_for",
"(",
"$",
"this",
"->",
"content",
")",
";",
"if",
"(",
"$"... | Uploads the content in multiple ranges and completes this session.
@return DriveItemProxy
The drive item created.
@todo Support retries on errors. | [
"Uploads",
"the",
"content",
"in",
"multiple",
"ranges",
"and",
"completes",
"this",
"session",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/UploadSessionProxy.php#L110-L166 |
40,730 | krizalys/onedrive-php-sdk | src/Client.php | Client.getLogInUrl | public function getLogInUrl(array $scopes, $redirectUri)
{
$redirectUri = (string) $redirectUri;
$this->_state->redirect_uri = $redirectUri;
$values = [
'client_id' => $this->clientId,
'response_type' => 'code',
'redirect_uri' => $redirectUri,
'scope' => implode(' ', $scopes),
'response_mode' => 'query',
];
$query = http_build_query($values, '', '&', PHP_QUERY_RFC3986);
// When visiting this URL and authenticating successfully, the agent is
// redirected to the redirect URI, with a code passed in the query
// string (the name of the variable is "code"). This is suitable for
// PHP.
return self::AUTH_URL . "?$query";
} | php | public function getLogInUrl(array $scopes, $redirectUri)
{
$redirectUri = (string) $redirectUri;
$this->_state->redirect_uri = $redirectUri;
$values = [
'client_id' => $this->clientId,
'response_type' => 'code',
'redirect_uri' => $redirectUri,
'scope' => implode(' ', $scopes),
'response_mode' => 'query',
];
$query = http_build_query($values, '', '&', PHP_QUERY_RFC3986);
// When visiting this URL and authenticating successfully, the agent is
// redirected to the redirect URI, with a code passed in the query
// string (the name of the variable is "code"). This is suitable for
// PHP.
return self::AUTH_URL . "?$query";
} | [
"public",
"function",
"getLogInUrl",
"(",
"array",
"$",
"scopes",
",",
"$",
"redirectUri",
")",
"{",
"$",
"redirectUri",
"=",
"(",
"string",
")",
"$",
"redirectUri",
";",
"$",
"this",
"->",
"_state",
"->",
"redirect_uri",
"=",
"$",
"redirectUri",
";",
"$... | Gets the URL of the log in form. After login, the browser is redirected
to the redirect URI, and a code is passed as a query string parameter to
this URI.
The browser is also redirected to the redirect URI if the user is already
logged in.
@param array $scopes
The OneDrive scopes requested by the application. Supported
values:
- 'offline_access'
- 'files.read'
- 'files.read.all'
- 'files.readwrite'
- 'files.readwrite.all'
@param string $redirectUri
The URI to which to redirect to upon successful log in.
@return string
The log in URL. | [
"Gets",
"the",
"URL",
"of",
"the",
"log",
"in",
"form",
".",
"After",
"login",
"the",
"browser",
"is",
"redirected",
"to",
"the",
"redirect",
"URI",
"and",
"a",
"code",
"is",
"passed",
"as",
"a",
"query",
"string",
"parameter",
"to",
"this",
"URI",
"."... | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L153-L173 |
40,731 | krizalys/onedrive-php-sdk | src/Client.php | Client.getTokenExpire | public function getTokenExpire()
{
return $this->_state->token->obtained
+ $this->_state->token->data->expires_in - time();
} | php | public function getTokenExpire()
{
return $this->_state->token->obtained
+ $this->_state->token->data->expires_in - time();
} | [
"public",
"function",
"getTokenExpire",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_state",
"->",
"token",
"->",
"obtained",
"+",
"$",
"this",
"->",
"_state",
"->",
"token",
"->",
"data",
"->",
"expires_in",
"-",
"time",
"(",
")",
";",
"}"
] | Gets the access token expiration delay.
@return int
The token expiration delay, in seconds. | [
"Gets",
"the",
"access",
"token",
"expiration",
"delay",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L181-L185 |
40,732 | krizalys/onedrive-php-sdk | src/Client.php | Client.getAccessTokenStatus | public function getAccessTokenStatus()
{
if (null === $this->_state->token) {
return 0;
}
$remaining = $this->getTokenExpire();
if (0 >= $remaining) {
return -2;
}
if (60 >= $remaining) {
return -1;
}
return 1;
} | php | public function getAccessTokenStatus()
{
if (null === $this->_state->token) {
return 0;
}
$remaining = $this->getTokenExpire();
if (0 >= $remaining) {
return -2;
}
if (60 >= $remaining) {
return -1;
}
return 1;
} | [
"public",
"function",
"getAccessTokenStatus",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_state",
"->",
"token",
")",
"{",
"return",
"0",
";",
"}",
"$",
"remaining",
"=",
"$",
"this",
"->",
"getTokenExpire",
"(",
")",
";",
"if",
"("... | Gets the status of the current access token.
@return int
The status of the current access token:
- 0 No access token.
- -1 Access token will expire soon (1 minute or less).
- -2 Access token is expired.
- 1 Access token is valid. | [
"Gets",
"the",
"status",
"of",
"the",
"current",
"access",
"token",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L197-L214 |
40,733 | krizalys/onedrive-php-sdk | src/Client.php | Client.obtainAccessToken | public function obtainAccessToken($clientSecret, $code)
{
if (null === $this->_state->redirect_uri) {
throw new \Exception(
'The state\'s redirect URI must be set to call'
. ' obtainAccessToken()'
);
}
$values = [
'client_id' => $this->clientId,
'redirect_uri' => $this->_state->redirect_uri,
'client_secret' => (string) $clientSecret,
'code' => (string) $code,
'grant_type' => 'authorization_code',
];
$response = $this->httpClient->post(
self::TOKEN_URL,
['form_params' => $values]
);
$body = $response->getBody();
$data = json_decode($body);
if ($data === null) {
throw new \Exception('json_decode() failed');
}
$this->_state->redirect_uri = null;
$this->_state->token = (object) [
'obtained' => time(),
'data' => $data,
];
$this->graph->setAccessToken($this->_state->token->data->access_token);
} | php | public function obtainAccessToken($clientSecret, $code)
{
if (null === $this->_state->redirect_uri) {
throw new \Exception(
'The state\'s redirect URI must be set to call'
. ' obtainAccessToken()'
);
}
$values = [
'client_id' => $this->clientId,
'redirect_uri' => $this->_state->redirect_uri,
'client_secret' => (string) $clientSecret,
'code' => (string) $code,
'grant_type' => 'authorization_code',
];
$response = $this->httpClient->post(
self::TOKEN_URL,
['form_params' => $values]
);
$body = $response->getBody();
$data = json_decode($body);
if ($data === null) {
throw new \Exception('json_decode() failed');
}
$this->_state->redirect_uri = null;
$this->_state->token = (object) [
'obtained' => time(),
'data' => $data,
];
$this->graph->setAccessToken($this->_state->token->data->access_token);
} | [
"public",
"function",
"obtainAccessToken",
"(",
"$",
"clientSecret",
",",
"$",
"code",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_state",
"->",
"redirect_uri",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The state\\'s redirect URI must be... | Obtains a new access token from OAuth. This token is valid for one hour.
@param string $clientSecret
The OneDrive client secret.
@param string $code
The code returned by OneDrive after successful log in.
@throws Exception
Thrown if the redirect URI of this Client instance's state is not
set.
@throws Exception
Thrown if the HTTP response body cannot be JSON-decoded. | [
"Obtains",
"a",
"new",
"access",
"token",
"from",
"OAuth",
".",
"This",
"token",
"is",
"valid",
"for",
"one",
"hour",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L230-L267 |
40,734 | krizalys/onedrive-php-sdk | src/Client.php | Client.renewAccessToken | public function renewAccessToken($clientSecret)
{
if (null === $this->_state->token->data->refresh_token) {
throw new \Exception(
'The refresh token is not set or no permission for'
. ' \'wl.offline_access\' was given to renew the token'
);
}
$values = [
'client_id' => $this->clientId,
'client_secret' => $clientSecret,
'grant_type' => 'refresh_token',
'refresh_token' => $this->_state->token->data->refresh_token,
];
$response = $this->httpClient->post(
self::TOKEN_URL,
['form_params' => $values]
);
$body = $response->getBody();
$data = json_decode($body);
if ($data === null) {
throw new \Exception('json_decode() failed');
}
$this->_state->token = (object) [
'obtained' => time(),
'data' => $data,
];
} | php | public function renewAccessToken($clientSecret)
{
if (null === $this->_state->token->data->refresh_token) {
throw new \Exception(
'The refresh token is not set or no permission for'
. ' \'wl.offline_access\' was given to renew the token'
);
}
$values = [
'client_id' => $this->clientId,
'client_secret' => $clientSecret,
'grant_type' => 'refresh_token',
'refresh_token' => $this->_state->token->data->refresh_token,
];
$response = $this->httpClient->post(
self::TOKEN_URL,
['form_params' => $values]
);
$body = $response->getBody();
$data = json_decode($body);
if ($data === null) {
throw new \Exception('json_decode() failed');
}
$this->_state->token = (object) [
'obtained' => time(),
'data' => $data,
];
} | [
"public",
"function",
"renewAccessToken",
"(",
"$",
"clientSecret",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_state",
"->",
"token",
"->",
"data",
"->",
"refresh_token",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The refresh token is ... | Renews the access token from OAuth. This token is valid for one hour.
@param string $clientSecret
The client secret. | [
"Renews",
"the",
"access",
"token",
"from",
"OAuth",
".",
"This",
"token",
"is",
"valid",
"for",
"one",
"hour",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L275-L307 |
40,735 | krizalys/onedrive-php-sdk | src/Client.php | Client.createFolder | public function createFolder($name, $parentId = null, $description = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $parentId !== null ?
$this->getDriveItemById($drive->id, $parentId)
: $drive->getRoot();
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->createFolder($name, $options);
$options = $this->buildOptions($item, ['parent_id' => $parentId]);
return new Folder($this, $item->id, $options);
} | php | public function createFolder($name, $parentId = null, $description = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $parentId !== null ?
$this->getDriveItemById($drive->id, $parentId)
: $drive->getRoot();
$options = [];
if ($description !== null) {
$options += [
'description' => (string) $description,
];
}
$item = $item->createFolder($name, $options);
$options = $this->buildOptions($item, ['parent_id' => $parentId]);
return new Folder($this, $item->id, $options);
} | [
"public",
"function",
"createFolder",
"(",
"$",
"name",
",",
"$",
"parentId",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\... | Creates a folder in the current OneDrive account.
@param string $name
The name of the OneDrive folder to be created.
@param null|string $parentId
The ID of the OneDrive folder into which to create the OneDrive
folder, or null to create it in the OneDrive root folder. Default:
null.
@param null|string $description
The description of the OneDrive folder to be created, or null to
create it without a description. Default: null.
@return Folder
The folder created, as a Folder instance referencing to the
OneDrive folder created.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()
instead. | [
"Creates",
"a",
"folder",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L655-L683 |
40,736 | krizalys/onedrive-php-sdk | src/Client.php | Client.createFile | public function createFile(
$name,
$parentId = null,
$content = '',
array $options = []
) {
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $parentId !== null ?
$this->getDriveItemById($drive->id, $parentId)
: $drive->getRoot();
$item = $item->upload($name, $content);
$options = $this->buildOptions($item, ['parent_id' => $parentId]);
return new File($this, $item->id, $options);
} | php | public function createFile(
$name,
$parentId = null,
$content = '',
array $options = []
) {
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $parentId !== null ?
$this->getDriveItemById($drive->id, $parentId)
: $drive->getRoot();
$item = $item->upload($name, $content);
$options = $this->buildOptions($item, ['parent_id' => $parentId]);
return new File($this, $item->id, $options);
} | [
"public",
"function",
"createFile",
"(",
"$",
"name",
",",
"$",
"parentId",
"=",
"null",
",",
"$",
"content",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in... | Creates a file in the current OneDrive account.
@param string $name
The name of the OneDrive file to be created.
@param null|string $parentId
The ID of the OneDrive folder into which to create the OneDrive
file, or null to create it in the OneDrive root folder. Default:
null.
@param string|resource|\GuzzleHttp\Psr7\Stream $content
The content of the OneDrive file to be created, as a string or as
a resource to an already opened file. Default: ''.
@param array $options
The options.
@return File
The file created, as File instance referencing to the OneDrive
file created.
@throws Exception
Thrown on I/O errors.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::upload() instead.
@todo Support name conflict behavior.
@todo Support content type in options. | [
"Creates",
"a",
"file",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L712-L736 |
40,737 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchDriveItem | public function fetchDriveItem($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getDriveItemById() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return $this->isFolder($item) ?
new Folder($this, $item->id, $options)
: new File($this, $item->id, $options);
} | php | public function fetchDriveItem($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getDriveItemById() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return $this->isFolder($item) ?
new Folder($this, $item->id, $options)
: new File($this, $item->id, $options);
} | [
"public",
"function",
"fetchDriveItem",
"(",
"$",
"driveItemId",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getDriveItemById() instead.'",
",",
"__METHOD__",
")"... | Fetches a drive item from the current OneDrive account.
@param null|string $driveItemId
The unique ID of the OneDrive drive item to fetch, or null to
fetch the OneDrive root folder. Default: null.
@return object
The drive item fetched, as a DriveItem instance referencing to
the OneDrive drive item fetched.
@deprecated Use Krizalys\Onedrive\Client::getDriveItemById() instead. | [
"Fetches",
"a",
"drive",
"item",
"from",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L751-L771 |
40,738 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchRoot | public function fetchRoot()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getRoot() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$item = $this->getRoot();
$options = $this->buildOptions($item);
return new Folder($this, $item->id, $options);
} | php | public function fetchRoot()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getRoot() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$item = $this->getRoot();
$options = $this->buildOptions($item);
return new Folder($this, $item->id, $options);
} | [
"public",
"function",
"fetchRoot",
"(",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getRoot() instead.'",
",",
"__METHOD__",
")",
";",
"@",
"trigger_error",
"(",
"$",
"mes... | Fetches the root folder from the current OneDrive account.
@return Folder
The root folder, as a Folder instance referencing to the OneDrive
root folder.
@deprecated Use Krizalys\Onedrive\Client::getRoot() instead. | [
"Fetches",
"the",
"root",
"folder",
"from",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L782-L795 |
40,739 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchPics | public function fetchPics()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getSpecialFolder() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$item = $this->getSpecialFolder('photos');
$options = $this->buildOptions($item);
return new Folder($this, $item->id, $options);
} | php | public function fetchPics()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getSpecialFolder() instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$item = $this->getSpecialFolder('photos');
$options = $this->buildOptions($item);
return new Folder($this, $item->id, $options);
} | [
"public",
"function",
"fetchPics",
"(",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getSpecialFolder() instead.'",
",",
"__METHOD__",
")",
";",
"@",
"trigger_error",
"(",
"$... | Fetches the "Pictures" folder from the current OneDrive account.
@return Folder
The "Pictures" folder, as a Folder instance referencing to the
OneDrive "Pictures" folder.
@deprecated Use Krizalys\Onedrive\Client::getSpecialFolder() instead. | [
"Fetches",
"the",
"Pictures",
"folder",
"from",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L854-L867 |
40,740 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchProperties | public function fetchProperties($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getDriveItemById() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = $this->buildOptions(
$item,
[
'id' => $item->id,
'parent_id' => $driveItemId,
]
);
return (object) $options;
} | php | public function fetchProperties($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getDriveItemById() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = $this->buildOptions(
$item,
[
'id' => $item->id,
'parent_id' => $driveItemId,
]
);
return (object) $options;
} | [
"public",
"function",
"fetchProperties",
"(",
"$",
"driveItemId",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getDriveItemById() instead'",
",",
"__METHOD__",
")"... | Fetches the properties of a drive item in the current OneDrive account.
@param null|string $driveItemId
The drive item ID, or null to fetch the OneDrive root folder.
Default: null.
@return object
The properties of the drive item fetched.
@deprecated Use Krizalys\Onedrive\Client::getDriveItemById() instead. | [
"Fetches",
"the",
"properties",
"of",
"a",
"drive",
"item",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L881-L905 |
40,741 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchDriveItems | public function fetchDriveItems($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
return array_map(function (DriveItemProxy $item) use ($driveItemId) {
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return $this->isFolder($item) ?
new Folder($this, $item->id, $options)
: new File($this, $item->id, $options);
}, $item->children);
} | php | public function fetchDriveItems($driveItemId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
return array_map(function (DriveItemProxy $item) use ($driveItemId) {
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return $this->isFolder($item) ?
new Folder($this, $item->id, $options)
: new File($this, $item->id, $options);
}, $item->children);
} | [
"public",
"function",
"fetchDriveItems",
"(",
"$",
"driveItemId",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Proxy\\DriveItemProxy::children'",
".",
"' instead.'",
",",
... | Fetches the drive items in a folder in the current OneDrive account.
@param null|string $driveItemId
The drive item ID, or null to fetch the OneDrive root folder.
Default: null.
@return array
The drive items in the folder fetched, as DriveItem instances
referencing OneDrive drive items.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::children
instead. | [
"Fetches",
"the",
"drive",
"items",
"in",
"a",
"folder",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L921-L944 |
40,742 | krizalys/onedrive-php-sdk | src/Client.php | Client.updateDriveItem | public function updateDriveItem($driveItemId, $properties = [], $temp = false)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::rename()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = (array) $properties;
if (array_key_exists('name', $options)) {
$name = $options['name'];
unset($options['name']);
} else {
$name = $item->name;
}
$item = $item->rename($name, $options);
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return new Folder($this, $item->id, $options);
} | php | public function updateDriveItem($driveItemId, $properties = [], $temp = false)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::rename()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $driveItemId !== null ?
$this->getDriveItemById($drive->id, $driveItemId)
: $drive->getRoot();
$options = (array) $properties;
if (array_key_exists('name', $options)) {
$name = $options['name'];
unset($options['name']);
} else {
$name = $item->name;
}
$item = $item->rename($name, $options);
$options = $this->buildOptions($item, ['parent_id' => $driveItemId]);
return new Folder($this, $item->id, $options);
} | [
"public",
"function",
"updateDriveItem",
"(",
"$",
"driveItemId",
",",
"$",
"properties",
"=",
"[",
"]",
",",
"$",
"temp",
"=",
"false",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\... | Updates the properties of a drive item in the current OneDrive account.
@param string $driveItemId
The unique ID of the drive item to update.
@param array|object $properties
The properties to update. Default: [].
@param bool $temp
Option to allow save to a temporary file in case of large files.
@throws Exception
Thrown on I/O errors.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::rename() instead. | [
"Updates",
"the",
"properties",
"of",
"a",
"drive",
"item",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L961-L990 |
40,743 | krizalys/onedrive-php-sdk | src/Client.php | Client.moveDriveItem | public function moveDriveItem($driveItemId, $destinationId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $this->getDriveItemById($drive->id, $driveItemId);
$destination = $destinationId !== null ?
$this->getDriveItemById($drive->id, $destinationId)
: $drive->getRoot();
$item->move($destination);
} | php | public function moveDriveItem($driveItemId, $destinationId = null)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $this->getDriveItemById($drive->id, $driveItemId);
$destination = $destinationId !== null ?
$this->getDriveItemById($drive->id, $destinationId)
: $drive->getRoot();
$item->move($destination);
} | [
"public",
"function",
"moveDriveItem",
"(",
"$",
"driveItemId",
",",
"$",
"destinationId",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Proxy\\DriveItemProxy::move()'",
... | Moves a drive item into another folder.
@param string $driveItemId
The unique ID of the drive item to move.
@param null|string $destinationId
The unique ID of the folder into which to move the drive item, or
null to move it to the OneDrive root folder. Default: null.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::move() instead. | [
"Moves",
"a",
"drive",
"item",
"into",
"another",
"folder",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L1003-L1021 |
40,744 | krizalys/onedrive-php-sdk | src/Client.php | Client.deleteDriveItem | public function deleteDriveItem($driveItemId)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::delete()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $this->getDriveItemById($drive->id, $driveItemId);
$item->delete();
} | php | public function deleteDriveItem($driveItemId)
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::delete()'
. ' instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$item = $this->getDriveItemById($drive->id, $driveItemId);
$item->delete();
} | [
"public",
"function",
"deleteDriveItem",
"(",
"$",
"driveItemId",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Proxy\\DriveItemProxy::delete()'",
".",
"' instead'",
",",
"__METHOD__",
... | Deletes a drive item in the current OneDrive account.
@param string $driveItemId
The unique ID of the drive item to delete.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::delete() instead. | [
"Deletes",
"a",
"drive",
"item",
"in",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L1063-L1076 |
40,745 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchQuota | public function fetchQuota()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveProxy::quota instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$quota = $drive->quota;
return (object) [
'quota' => $quota->total,
'available' => $quota->remaining,
];
} | php | public function fetchQuota()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveProxy::quota instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $this->getMyDrive();
$quota = $drive->quota;
return (object) [
'quota' => $quota->total,
'available' => $quota->remaining,
];
} | [
"public",
"function",
"fetchQuota",
"(",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Proxy\\DriveProxy::quota instead'",
",",
"__METHOD__",
")",
";",
"@",
"trigger_error",
"(",
"$",... | Fetches the quota of the current OneDrive account.
@return object
An object with the following properties:
- 'quota' (int) The total space, in bytes.
- 'available' (int) The available space, in bytes.
@deprecated Use Krizalys\Onedrive\Proxy\DriveProxy::quota instead. | [
"Fetches",
"the",
"quota",
"of",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L1088-L1104 |
40,746 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchRecentDocs | public function fetchRecentDocs()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getRecent() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$items = $this->getRecent();
return (object) [
'data' => array_map(function (DriveItemProxy $item) {
return (object) $this->buildOptions($item);
}, $items),
];
} | php | public function fetchRecentDocs()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getRecent() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$items = $this->getRecent();
return (object) [
'data' => array_map(function (DriveItemProxy $item) {
return (object) $this->buildOptions($item);
}, $items),
];
} | [
"public",
"function",
"fetchRecentDocs",
"(",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getRecent() instead'",
",",
"__METHOD__",
")",
";",
"@",
"trigger_error",
"(",
"$",... | Fetches the recent documents uploaded to the current OneDrive account.
@return object
An object with the following properties:
- 'data' (array) The list of the recent documents uploaded.
@deprecated Use Krizalys\Onedrive\Client::getRecent() instead. | [
"Fetches",
"the",
"recent",
"documents",
"uploaded",
"to",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L1115-L1131 |
40,747 | krizalys/onedrive-php-sdk | src/Client.php | Client.fetchShared | public function fetchShared()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getShared() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$items = $this->getShared();
return (object) [
'data' => array_map(function (DriveItemProxy $item) {
return (object) $this->buildOptions($item);
}, $items),
];
} | php | public function fetchShared()
{
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Client::getShared() instead',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$items = $this->getShared();
return (object) [
'data' => array_map(function (DriveItemProxy $item) {
return (object) $this->buildOptions($item);
}, $items),
];
} | [
"public",
"function",
"fetchShared",
"(",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizalys\\Onedrive\\Client::getShared() instead'",
",",
"__METHOD__",
")",
";",
"@",
"trigger_error",
"(",
"$",
"... | Fetches the drive items shared with the current OneDrive account.
@return object
An object with the following properties:
- 'data' (array) The list of the shared drive items.
@deprecated Use Krizalys\Onedrive\Client::getShared() instead. | [
"Fetches",
"the",
"drive",
"items",
"shared",
"with",
"the",
"current",
"OneDrive",
"account",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L1142-L1158 |
40,748 | krizalys/onedrive-php-sdk | src/File.php | File.fetchContent | public function fetchContent(array $options = [])
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::content'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
return (string) $item->content;
} | php | public function fetchContent(array $options = [])
{
$client = $this->_client;
$message = sprintf(
'%s() is deprecated and will be removed in version 3;'
. ' use Krizalys\Onedrive\Proxy\DriveItemProxy::content'
. ' instead.',
__METHOD__
);
@trigger_error($message, E_USER_DEPRECATED);
$drive = $client->getMyDrive();
$item = $client->getDriveItemById($drive->id, $this->_id);
return (string) $item->content;
} | [
"public",
"function",
"fetchContent",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"_client",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s() is deprecated and will be removed in version 3;'",
".",
"' use Krizaly... | Fetches the content of the OneDrive file referenced by this File
instance.
@param array $options
Extra cURL options to apply.
@return string
The content of the OneDrive file referenced by this File
instance.
@todo Should somewhat return the content-type as well; this information
is not disclosed by OneDrive.
@deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::content instead. | [
"Fetches",
"the",
"content",
"of",
"the",
"OneDrive",
"file",
"referenced",
"by",
"this",
"File",
"instance",
"."
] | 80fd1be8e149190e44dd5a055bad09bafda2c330 | https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/File.php#L48-L64 |
40,749 | duncan3dc/speaker | src/Providers/AcapelaProvider.php | AcapelaProvider.getVoice | private function getVoice(string $voice): string
{
$voice = trim($voice);
if (strlen($voice) < 3) {
throw new InvalidArgumentException("Unexpected voice name ({$voice}), names should be at least 3 characters long");
}
return strtolower($voice);
} | php | private function getVoice(string $voice): string
{
$voice = trim($voice);
if (strlen($voice) < 3) {
throw new InvalidArgumentException("Unexpected voice name ({$voice}), names should be at least 3 characters long");
}
return strtolower($voice);
} | [
"private",
"function",
"getVoice",
"(",
"string",
"$",
"voice",
")",
":",
"string",
"{",
"$",
"voice",
"=",
"trim",
"(",
"$",
"voice",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"voice",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"InvalidArgumentExceptio... | Check if the voce is valid, and convert it to the required format.
@param string $voice The voice to use
@return string | [
"Check",
"if",
"the",
"voce",
"is",
"valid",
"and",
"convert",
"it",
"to",
"the",
"required",
"format",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/AcapelaProvider.php#L73-L81 |
40,750 | duncan3dc/speaker | src/Providers/AcapelaProvider.php | AcapelaProvider.withVoice | public function withVoice(string $voice): self
{
$provider = clone $this;
$provider->voice = $this->getVoice($voice);
return $provider;
} | php | public function withVoice(string $voice): self
{
$provider = clone $this;
$provider->voice = $this->getVoice($voice);
return $provider;
} | [
"public",
"function",
"withVoice",
"(",
"string",
"$",
"voice",
")",
":",
"self",
"{",
"$",
"provider",
"=",
"clone",
"$",
"this",
";",
"$",
"provider",
"->",
"voice",
"=",
"$",
"this",
"->",
"getVoice",
"(",
"$",
"voice",
")",
";",
"return",
"$",
... | Set the voice to use.
Visit http://www.acapela-vaas.com/ReleasedDocumentation/voices_list.php for available voices
@param string $voice The voice to use (eg 'Graham')
@return self | [
"Set",
"the",
"voice",
"to",
"use",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/AcapelaProvider.php#L93-L100 |
40,751 | duncan3dc/speaker | src/Providers/AcapelaProvider.php | AcapelaProvider.withSpeed | public function withSpeed(int $speed): self
{
$provider = clone $this;
$provider->speed = $this->getSpeed($speed);
return $provider;
} | php | public function withSpeed(int $speed): self
{
$provider = clone $this;
$provider->speed = $this->getSpeed($speed);
return $provider;
} | [
"public",
"function",
"withSpeed",
"(",
"int",
"$",
"speed",
")",
":",
"self",
"{",
"$",
"provider",
"=",
"clone",
"$",
"this",
";",
"$",
"provider",
"->",
"speed",
"=",
"$",
"this",
"->",
"getSpeed",
"(",
"$",
"speed",
")",
";",
"return",
"$",
"pr... | Set the speech rate to use.
@param int $speed The speech rate to use (between 60 and 360)
@return self | [
"Set",
"the",
"speech",
"rate",
"to",
"use",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/AcapelaProvider.php#L127-L134 |
40,752 | duncan3dc/speaker | src/Providers/ResponsiveVoiceProvider.php | ResponsiveVoiceProvider.withLanguage | public function withLanguage(string $language): self
{
$provider = clone $this;
$provider->language = $this->getLanguage($language);
return $provider;
} | php | public function withLanguage(string $language): self
{
$provider = clone $this;
$provider->language = $this->getLanguage($language);
return $provider;
} | [
"public",
"function",
"withLanguage",
"(",
"string",
"$",
"language",
")",
":",
"self",
"{",
"$",
"provider",
"=",
"clone",
"$",
"this",
";",
"$",
"provider",
"->",
"language",
"=",
"$",
"this",
"->",
"getLanguage",
"(",
"$",
"language",
")",
";",
"ret... | Set the language to use.
@param string $language The language to use (eg 'en')
@return self | [
"Set",
"the",
"language",
"to",
"use",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/ResponsiveVoiceProvider.php#L69-L76 |
40,753 | duncan3dc/speaker | src/Providers/AbstractProvider.php | AbstractProvider.getClient | public function getClient(): ClientInterface
{
if ($this->client === null) {
$this->client = new Client();
}
return $this->client;
} | php | public function getClient(): ClientInterface
{
if ($this->client === null) {
$this->client = new Client();
}
return $this->client;
} | [
"public",
"function",
"getClient",
"(",
")",
":",
"ClientInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"client",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"client",
... | Get the guzzle client.
@return ClientInterface | [
"Get",
"the",
"guzzle",
"client",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/AbstractProvider.php#L40-L47 |
40,754 | duncan3dc/speaker | src/Providers/AbstractProvider.php | AbstractProvider.sendRequest | protected function sendRequest(string $hostname, array $params): string
{
$url = $hostname . "?" . http_build_query($params);
$response = $this->getClient()->request("GET", $url);
if ($response->getStatusCode() != "200") {
throw new ProviderException("Failed to call the external text-to-speech service");
}
return $response->getBody();
} | php | protected function sendRequest(string $hostname, array $params): string
{
$url = $hostname . "?" . http_build_query($params);
$response = $this->getClient()->request("GET", $url);
if ($response->getStatusCode() != "200") {
throw new ProviderException("Failed to call the external text-to-speech service");
}
return $response->getBody();
} | [
"protected",
"function",
"sendRequest",
"(",
"string",
"$",
"hostname",
",",
"array",
"$",
"params",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"hostname",
".",
"\"?\"",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"response",
"=",
"... | Send a http request.
@param string $hostname The hostname to send the request to
@param string[] $params The parameters of the request
@return string The response body | [
"Send",
"a",
"http",
"request",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/Providers/AbstractProvider.php#L83-L94 |
40,755 | duncan3dc/speaker | src/TextToSpeech.php | TextToSpeech.getAudioData | public function getAudioData(): string
{
if ($this->data === null) {
$this->data = $this->provider->textToSpeech($this->text);
}
return $this->data;
} | php | public function getAudioData(): string
{
if ($this->data === null) {
$this->data = $this->provider->textToSpeech($this->text);
}
return $this->data;
} | [
"public",
"function",
"getAudioData",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"provider",
"->",
"textToSpeech",
"(",
"$",
"this",
"->",
"text",
... | Get the audio for this text.
@return string The audio data | [
"Get",
"the",
"audio",
"for",
"this",
"text",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/TextToSpeech.php#L51-L58 |
40,756 | duncan3dc/speaker | src/TextToSpeech.php | TextToSpeech.generateFilename | public function generateFilename(): string
{
$options = $this->provider->getOptions();
$options["text"] = $this->text;
$data = serialize($options);
return md5($data) . "." . $this->provider->getFormat();
} | php | public function generateFilename(): string
{
$options = $this->provider->getOptions();
$options["text"] = $this->text;
$data = serialize($options);
return md5($data) . "." . $this->provider->getFormat();
} | [
"public",
"function",
"generateFilename",
"(",
")",
":",
"string",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"provider",
"->",
"getOptions",
"(",
")",
";",
"$",
"options",
"[",
"\"text\"",
"]",
"=",
"$",
"this",
"->",
"text",
";",
"$",
"data",
"="... | Generate the filename to be used for this text.
@return string | [
"Generate",
"the",
"filename",
"to",
"be",
"used",
"for",
"this",
"text",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/TextToSpeech.php#L66-L75 |
40,757 | duncan3dc/speaker | src/TextToSpeech.php | TextToSpeech.save | public function save(string $filename): TextToSpeechInterface
{
$result = file_put_contents($filename, $this->getAudioData());
if ($result === false) {
throw new RuntimeException("Unable to save the file ({$filename})");
}
return $this;
} | php | public function save(string $filename): TextToSpeechInterface
{
$result = file_put_contents($filename, $this->getAudioData());
if ($result === false) {
throw new RuntimeException("Unable to save the file ({$filename})");
}
return $this;
} | [
"public",
"function",
"save",
"(",
"string",
"$",
"filename",
")",
":",
"TextToSpeechInterface",
"{",
"$",
"result",
"=",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"getAudioData",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"==... | Create an audio file on the filesystem.
@param string $filename The filename to write to
@return $this | [
"Create",
"an",
"audio",
"file",
"on",
"the",
"filesystem",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/TextToSpeech.php#L85-L94 |
40,758 | duncan3dc/speaker | src/TextToSpeech.php | TextToSpeech.getFile | public function getFile(string $path = null): string
{
if ($path === null) {
$path = sys_get_temp_dir();
}
$filename = $path . "/" . $this->generateFilename();
if (!is_file($filename)) {
$this->save($filename);
}
return $filename;
} | php | public function getFile(string $path = null): string
{
if ($path === null) {
$path = sys_get_temp_dir();
}
$filename = $path . "/" . $this->generateFilename();
if (!is_file($filename)) {
$this->save($filename);
}
return $filename;
} | [
"public",
"function",
"getFile",
"(",
"string",
"$",
"path",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"path",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"path",
".",
... | Store the audio file on the filesystem.
This function uses caching so if the file already exists
a call to the text-to-speech service is not made.
@param string $path The path to the directory to store the file in
@return string The full path and filename | [
"Store",
"the",
"audio",
"file",
"on",
"the",
"filesystem",
"."
] | 17c2f8cba5c702b7495e76aa80a18250b1ce895c | https://github.com/duncan3dc/speaker/blob/17c2f8cba5c702b7495e76aa80a18250b1ce895c/src/TextToSpeech.php#L107-L120 |
40,759 | Modelizer/Laravel-Selenium | src/Services/WaitForElement.php | WaitForElement.waitForElement | protected function waitForElement($type, $value, $timeout)
{
if (!in_array($type, $this->waitForTypes)) {
throw new \Exception('Invalid wait for element type to wait for on the page');
}
$webdriver = $this;
$this->waitUntil(function () use ($type, $value, $webdriver) {
$function = 'by'.$type;
try {
$webdriver->$function($value);
return true;
} catch (\Exception $e) {
return; // haven't found the element yet
}
}, $timeout);
} | php | protected function waitForElement($type, $value, $timeout)
{
if (!in_array($type, $this->waitForTypes)) {
throw new \Exception('Invalid wait for element type to wait for on the page');
}
$webdriver = $this;
$this->waitUntil(function () use ($type, $value, $webdriver) {
$function = 'by'.$type;
try {
$webdriver->$function($value);
return true;
} catch (\Exception $e) {
return; // haven't found the element yet
}
}, $timeout);
} | [
"protected",
"function",
"waitForElement",
"(",
"$",
"type",
",",
"$",
"value",
",",
"$",
"timeout",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"waitForTypes",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"("... | Generalized WaitsFor function to wait for a specific element with value
by the type passed.
@param $type The type of selector we are using to wait for
@param $value The value of the selector we are using
@param $timeout
@throws \Exception | [
"Generalized",
"WaitsFor",
"function",
"to",
"wait",
"for",
"a",
"specific",
"element",
"with",
"value",
"by",
"the",
"type",
"passed",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/WaitForElement.php#L21-L39 |
40,760 | Modelizer/Laravel-Selenium | src/Services/WaitForElement.php | WaitForElement.waitForElementsWithClass | protected function waitForElementsWithClass($class, $timeout = 2000)
{
try {
$this->waitForElement('ClassName', $class, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with the class name of "
.$class.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | php | protected function waitForElementsWithClass($class, $timeout = 2000)
{
try {
$this->waitForElement('ClassName', $class, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with the class name of "
.$class.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | [
"protected",
"function",
"waitForElementsWithClass",
"(",
"$",
"class",
",",
"$",
"timeout",
"=",
"2000",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"waitForElement",
"(",
"'ClassName'",
",",
"$",
"class",
",",
"$",
"timeout",
")",
";",
"}",
"catch",
"(",
... | Helper method to wait for an element with the specified class.
@param $class
@param int $timeout
@throws CannotFindElement
@return $this | [
"Helper",
"method",
"to",
"wait",
"for",
"an",
"element",
"with",
"the",
"specified",
"class",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/WaitForElement.php#L51-L61 |
40,761 | Modelizer/Laravel-Selenium | src/Services/WaitForElement.php | WaitForElement.waitForElementWithId | protected function waitForElementWithId($id, $timeout = 2000)
{
try {
$this->waitForElement('Id', $id, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with an ID of "
.$id.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | php | protected function waitForElementWithId($id, $timeout = 2000)
{
try {
$this->waitForElement('Id', $id, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with an ID of "
.$id.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | [
"protected",
"function",
"waitForElementWithId",
"(",
"$",
"id",
",",
"$",
"timeout",
"=",
"2000",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"waitForElement",
"(",
"'Id'",
",",
"$",
"id",
",",
"$",
"timeout",
")",
";",
"}",
"catch",
"(",
"\\",
"Except... | Helper method to wait for an element with the specified id.
@param $id
@param int $timeout
@throws CannotFindElement
@return $this | [
"Helper",
"method",
"to",
"wait",
"for",
"an",
"element",
"with",
"the",
"specified",
"id",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/WaitForElement.php#L73-L83 |
40,762 | Modelizer/Laravel-Selenium | src/Services/WaitForElement.php | WaitForElement.waitForElementWithXPath | protected function waitForElementWithXPath($xpath, $timeout = 2000)
{
try {
$this->waitForElement('XPath', $xpath, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with an XPath of "
.$xpath.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | php | protected function waitForElementWithXPath($xpath, $timeout = 2000)
{
try {
$this->waitForElement('XPath', $xpath, $timeout);
} catch (\Exception $e) {
throw new CannotFindElement("Can't find an element with an XPath of "
.$xpath.' within the time period of '.$timeout.' miliseconds');
}
return $this;
} | [
"protected",
"function",
"waitForElementWithXPath",
"(",
"$",
"xpath",
",",
"$",
"timeout",
"=",
"2000",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"waitForElement",
"(",
"'XPath'",
",",
"$",
"xpath",
",",
"$",
"timeout",
")",
";",
"}",
"catch",
"(",
"\\... | Helper method to wait for an element with the specified xpath.
@param $xpath
@param int $timeout
@throws CannotFindElement
@return $this | [
"Helper",
"method",
"to",
"wait",
"for",
"an",
"element",
"with",
"the",
"specified",
"xpath",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/WaitForElement.php#L95-L105 |
40,763 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.select | protected function select($value, $element)
{
$this->wd->findElement(WebDriverBy::cssSelector($element))->sendKeys($value);
return $this;
} | php | protected function select($value, $element)
{
$this->wd->findElement(WebDriverBy::cssSelector($element))->sendKeys($value);
return $this;
} | [
"protected",
"function",
"select",
"(",
"$",
"value",
",",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"wd",
"->",
"findElement",
"(",
"WebDriverBy",
"::",
"cssSelector",
"(",
"$",
"element",
")",
")",
"->",
"sendKeys",
"(",
"$",
"value",
")",
";",
... | "Select" a drop-down field.
@param $value
@param $element
@return $this | [
"Select",
"a",
"drop",
"-",
"down",
"field",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L53-L58 |
40,764 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.see | protected function see($text, $tag = 'body')
{
$this->assertContains($text, $this->getTextByTag($tag));
return $this;
} | php | protected function see($text, $tag = 'body')
{
$this->assertContains($text, $this->getTextByTag($tag));
return $this;
} | [
"protected",
"function",
"see",
"(",
"$",
"text",
",",
"$",
"tag",
"=",
"'body'",
")",
"{",
"$",
"this",
"->",
"assertContains",
"(",
"$",
"text",
",",
"$",
"this",
"->",
"getTextByTag",
"(",
"$",
"tag",
")",
")",
";",
"return",
"$",
"this",
";",
... | Assert that we see text within the specified tag
Defaults to the body tag.
@param $text
@param string $tag
@return $this | [
"Assert",
"that",
"we",
"see",
"text",
"within",
"the",
"specified",
"tag",
"Defaults",
"to",
"the",
"body",
"tag",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L69-L74 |
40,765 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.seePageIs | protected function seePageIs($path)
{
$this->assertEquals($this->wd->getCurrentURL(), $this->baseUrl.$path);
return $this;
} | php | protected function seePageIs($path)
{
$this->assertEquals($this->wd->getCurrentURL(), $this->baseUrl.$path);
return $this;
} | [
"protected",
"function",
"seePageIs",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"assertEquals",
"(",
"$",
"this",
"->",
"wd",
"->",
"getCurrentURL",
"(",
")",
",",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"path",
")",
";",
"return",
"$",
"this",
... | Assert the page is at the path that you specified.
@param $path
@return $this | [
"Assert",
"the",
"page",
"is",
"at",
"the",
"path",
"that",
"you",
"specified",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L105-L110 |
40,766 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.typeBySelectorType | private function typeBySelectorType($type, $value, $name, $clear = false)
{
$element = $this->wd->findElement(WebDriverBy::{$type}($name));
if ($clear) {
$element->clear();
}
$element->sendKeys($value);
return $this;
} | php | private function typeBySelectorType($type, $value, $name, $clear = false)
{
$element = $this->wd->findElement(WebDriverBy::{$type}($name));
if ($clear) {
$element->clear();
}
$element->sendKeys($value);
return $this;
} | [
"private",
"function",
"typeBySelectorType",
"(",
"$",
"type",
",",
"$",
"value",
",",
"$",
"name",
",",
"$",
"clear",
"=",
"false",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"wd",
"->",
"findElement",
"(",
"WebDriverBy",
"::",
"{",
"$",
"typ... | Abstraction for typing into a field with a specific selector type.
@param $type - one of 'Name', 'Id', 'CssSelector'
@param $value - value to enter into form element
@param $name - value to use for the selector $type
@param bool $clear - Whether or not to clear the input first on say an edit form
@throws CannotFindElement
@return $this | [
"Abstraction",
"for",
"typing",
"into",
"a",
"field",
"with",
"a",
"specific",
"selector",
"type",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L152-L163 |
40,767 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.typeByName | protected function typeByName($name, $value, $clear = false)
{
return $this->typeBySelectorType('name', $value, $name, $clear);
} | php | protected function typeByName($name, $value, $clear = false)
{
return $this->typeBySelectorType('name', $value, $name, $clear);
} | [
"protected",
"function",
"typeByName",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"clear",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"typeBySelectorType",
"(",
"'name'",
",",
"$",
"value",
",",
"$",
"name",
",",
"$",
"clear",
")",
";",... | Type a value into a form input by that inputs name.
@param $name
@param $value
@param bool $clear Whether or not to clear the input first on say an edit form
@return $this | [
"Type",
"a",
"value",
"into",
"a",
"form",
"input",
"by",
"that",
"inputs",
"name",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L174-L177 |
40,768 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.typeInformation | protected function typeInformation($information, $clear = false)
{
foreach ($information as $element => $item) {
$this->type($item, $element, $clear);
}
return $this;
} | php | protected function typeInformation($information, $clear = false)
{
foreach ($information as $element => $item) {
$this->type($item, $element, $clear);
}
return $this;
} | [
"protected",
"function",
"typeInformation",
"(",
"$",
"information",
",",
"$",
"clear",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"information",
"as",
"$",
"element",
"=>",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"type",
"(",
"$",
"item",
",",
"... | Function to type information as an array
The key of the array specifies the input name.
@param $information
@param $clear
@return $this | [
"Function",
"to",
"type",
"information",
"as",
"an",
"array",
"The",
"key",
"of",
"the",
"array",
"specifies",
"the",
"input",
"name",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L216-L223 |
40,769 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.click | protected function click($textOrId)
{
$element = $this->wd->findElement(WebDriverBy::xpath("//a[contains(., '{$textOrId}')]"));
try {
$element->click();
} catch (\Exception $e) {
throw new CannotClickElement('Cannot click the element with the text: '.$textOrId);
}
return $this;
} | php | protected function click($textOrId)
{
$element = $this->wd->findElement(WebDriverBy::xpath("//a[contains(., '{$textOrId}')]"));
try {
$element->click();
} catch (\Exception $e) {
throw new CannotClickElement('Cannot click the element with the text: '.$textOrId);
}
return $this;
} | [
"protected",
"function",
"click",
"(",
"$",
"textOrId",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"wd",
"->",
"findElement",
"(",
"WebDriverBy",
"::",
"xpath",
"(",
"\"//a[contains(., '{$textOrId}')]\"",
")",
")",
";",
"try",
"{",
"$",
"element",
"... | Click an element based on text passed in, or pass an Id or Name to find the element by.
@param $textOrId
@throws CannotClickElement Throws when the element cannot be clicked
@return $this | [
"Click",
"an",
"element",
"based",
"on",
"text",
"passed",
"in",
"or",
"pass",
"an",
"Id",
"or",
"Name",
"to",
"find",
"the",
"element",
"by",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L257-L268 |
40,770 | Modelizer/Laravel-Selenium | src/Services/InteractWithPage.php | InteractWithPage.findElement | protected function findElement($name)
{
try {
return $this->wd->findElement(WebDriverBy::id($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::name($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::cssSelector($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::xpath($name));
} catch (\Exception $e) {
}
throw new CannotFindElement('Cannot find element: '.$value.' isn\'t visible on the page');
} | php | protected function findElement($name)
{
try {
return $this->wd->findElement(WebDriverBy::id($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::name($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::cssSelector($name));
} catch (\Exception $e) {
}
try {
return $this->wd->findElement(WebDriverBy::xpath($name));
} catch (\Exception $e) {
}
throw new CannotFindElement('Cannot find element: '.$value.' isn\'t visible on the page');
} | [
"protected",
"function",
"findElement",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"wd",
"->",
"findElement",
"(",
"WebDriverBy",
"::",
"id",
"(",
"$",
"name",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
... | Will attempt to find an element by different patterns
If xpath is provided, will attempt to find by that first.
@param null $name
@throws CannotFindElement
@return \Facebook\WebDriver\Remote\RemoteWebElement | [
"Will",
"attempt",
"to",
"find",
"an",
"element",
"by",
"different",
"patterns",
"If",
"xpath",
"is",
"provided",
"will",
"attempt",
"to",
"find",
"by",
"that",
"first",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/InteractWithPage.php#L280-L303 |
40,771 | Modelizer/Laravel-Selenium | src/Console/BootSelenium.php | BootSelenium.getSeleniumServerQualifiedName | public function getSeleniumServerQualifiedName()
{
$files = opendir($binDirectory = base_path('vendor/bin'));
while (false !== ($file = readdir($files))) {
if (str_contains($file, 'selenium') && str_contains($file, $this->argument('serverVersion'))) {
return $binDirectory.DIRECTORY_SEPARATOR.$file;
}
}
return $this->downloadSelenium();
} | php | public function getSeleniumServerQualifiedName()
{
$files = opendir($binDirectory = base_path('vendor/bin'));
while (false !== ($file = readdir($files))) {
if (str_contains($file, 'selenium') && str_contains($file, $this->argument('serverVersion'))) {
return $binDirectory.DIRECTORY_SEPARATOR.$file;
}
}
return $this->downloadSelenium();
} | [
"public",
"function",
"getSeleniumServerQualifiedName",
"(",
")",
"{",
"$",
"files",
"=",
"opendir",
"(",
"$",
"binDirectory",
"=",
"base_path",
"(",
"'vendor/bin'",
")",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
... | Get selenium server qualified location.
@throws FileNotFoundException
@return string | [
"Get",
"selenium",
"server",
"qualified",
"location",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Console/BootSelenium.php#L76-L87 |
40,772 | Modelizer/Laravel-Selenium | src/Console/BootSelenium.php | BootSelenium.downloadSelenium | public function downloadSelenium()
{
$this->info('Downloading Selenium server file. Please wait...');
$process = new Process(base_path('vendor/bin/steward install '.$this->argument('serverVersion')));
$process->setTimeout(0);
$process->run();
return $process->getOutput();
} | php | public function downloadSelenium()
{
$this->info('Downloading Selenium server file. Please wait...');
$process = new Process(base_path('vendor/bin/steward install '.$this->argument('serverVersion')));
$process->setTimeout(0);
$process->run();
return $process->getOutput();
} | [
"public",
"function",
"downloadSelenium",
"(",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"'Downloading Selenium server file. Please wait...'",
")",
";",
"$",
"process",
"=",
"new",
"Process",
"(",
"base_path",
"(",
"'vendor/bin/steward install '",
".",
"$",
"this",
... | Download and get the file name of selenium server.
@return string selenium server file directory | [
"Download",
"and",
"get",
"the",
"file",
"name",
"of",
"selenium",
"server",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Console/BootSelenium.php#L94-L104 |
40,773 | Modelizer/Laravel-Selenium | src/Console/BootSelenium.php | BootSelenium.getWebDriver | protected function getWebDriver($driverName)
{
$config = $this->getConfig();
if (empty($config)) {
$this->warn('No web driver loaded.');
return '';
}
$driver = base_path("vendor/bin/{$this->getFileName()}");
if (!is_file($driver)) {
$this->call('selenium:web-driver:download', [
'driver' => $driverName,
]);
}
return "-Dwebdriver.{$this->dWebDriver[$driverName]}.driver={$driver}";
} | php | protected function getWebDriver($driverName)
{
$config = $this->getConfig();
if (empty($config)) {
$this->warn('No web driver loaded.');
return '';
}
$driver = base_path("vendor/bin/{$this->getFileName()}");
if (!is_file($driver)) {
$this->call('selenium:web-driver:download', [
'driver' => $driverName,
]);
}
return "-Dwebdriver.{$this->dWebDriver[$driverName]}.driver={$driver}";
} | [
"protected",
"function",
"getWebDriver",
"(",
"$",
"driverName",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"'No web driver loaded.... | Get web driver full qualified location.
@param $driverName
@return string | [
"Get",
"web",
"driver",
"full",
"qualified",
"location",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Console/BootSelenium.php#L113-L132 |
40,774 | Modelizer/Laravel-Selenium | src/Services/ManageWindow.php | ManageWindow.changeWindowSize | public function changeWindowSize(int $width = 1024, int $height = 768)
{
$this->wd->manage()->window()->setPosition(new WebDriverPoint($width, $height));
return $this;
} | php | public function changeWindowSize(int $width = 1024, int $height = 768)
{
$this->wd->manage()->window()->setPosition(new WebDriverPoint($width, $height));
return $this;
} | [
"public",
"function",
"changeWindowSize",
"(",
"int",
"$",
"width",
"=",
"1024",
",",
"int",
"$",
"height",
"=",
"768",
")",
"{",
"$",
"this",
"->",
"wd",
"->",
"manage",
"(",
")",
"->",
"window",
"(",
")",
"->",
"setPosition",
"(",
"new",
"WebDriver... | Change the current window's width and height.
@param int $width
@param int $height
@return $this | [
"Change",
"the",
"current",
"window",
"s",
"width",
"and",
"height",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/ManageWindow.php#L23-L28 |
40,775 | Modelizer/Laravel-Selenium | src/Services/ManageWindow.php | ManageWindow.setWidth | public function setWidth($width)
{
return $this->wd->manage()
->window()
->setPosition(new WebDriverPoint($width, self::BROWSER_HEIGHT));
} | php | public function setWidth($width)
{
return $this->wd->manage()
->window()
->setPosition(new WebDriverPoint($width, self::BROWSER_HEIGHT));
} | [
"public",
"function",
"setWidth",
"(",
"$",
"width",
")",
"{",
"return",
"$",
"this",
"->",
"wd",
"->",
"manage",
"(",
")",
"->",
"window",
"(",
")",
"->",
"setPosition",
"(",
"new",
"WebDriverPoint",
"(",
"$",
"width",
",",
"self",
"::",
"BROWSER_HEIG... | Set the current window's width.
@param $width
@return \Facebook\WebDriver\WebDriverWindow | [
"Set",
"the",
"current",
"window",
"s",
"width",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Services/ManageWindow.php#L37-L42 |
40,776 | Modelizer/Laravel-Selenium | src/Console/GetWebDriver.php | GetWebDriver.download | protected function download($client)
{
$resource = base_path('vendor/bin/driver-file');
if (is_file(base_path("vendor/bin/{$this->getFileName()}"))) {
if (!$this->confirm(ucfirst($this->argument('driver')).' web driver file already exists. Would you still like to download it?')) {
return false;
}
}
$this->info("Downloading {$this->driver} web driver for {$this->userOS}...");
$resource .= $this->getExtension();
// Downloading Driver
$client->request('get', $this->getConfig()['url'], [
'save_to' => \GuzzleHttp\Psr7\stream_for(fopen($resource, 'w')),
]);
return $resource;
} | php | protected function download($client)
{
$resource = base_path('vendor/bin/driver-file');
if (is_file(base_path("vendor/bin/{$this->getFileName()}"))) {
if (!$this->confirm(ucfirst($this->argument('driver')).' web driver file already exists. Would you still like to download it?')) {
return false;
}
}
$this->info("Downloading {$this->driver} web driver for {$this->userOS}...");
$resource .= $this->getExtension();
// Downloading Driver
$client->request('get', $this->getConfig()['url'], [
'save_to' => \GuzzleHttp\Psr7\stream_for(fopen($resource, 'w')),
]);
return $resource;
} | [
"protected",
"function",
"download",
"(",
"$",
"client",
")",
"{",
"$",
"resource",
"=",
"base_path",
"(",
"'vendor/bin/driver-file'",
")",
";",
"if",
"(",
"is_file",
"(",
"base_path",
"(",
"\"vendor/bin/{$this->getFileName()}\"",
")",
")",
")",
"{",
"if",
"("... | Downloading driver.
@param $client
@return bool|string | [
"Downloading",
"driver",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Console/GetWebDriver.php#L78-L98 |
40,777 | Modelizer/Laravel-Selenium | src/Console/GetWebDriver.php | GetWebDriver.unZip | public function unZip(&$resource)
{
$this->info("Unzipping $resource file...");
$zip = new ZipArchive();
if (!$zip->open($resource)) {
throw new \ErrorException("Unable to unzip downloaded file $resource.");
}
// Renaming chrome driver
$zip->extractTo(dirname($resource));
$zip->close();
return $this->cleanUp($resource);
} | php | public function unZip(&$resource)
{
$this->info("Unzipping $resource file...");
$zip = new ZipArchive();
if (!$zip->open($resource)) {
throw new \ErrorException("Unable to unzip downloaded file $resource.");
}
// Renaming chrome driver
$zip->extractTo(dirname($resource));
$zip->close();
return $this->cleanUp($resource);
} | [
"public",
"function",
"unZip",
"(",
"&",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"Unzipping $resource file...\"",
")",
";",
"$",
"zip",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"!",
"$",
"zip",
"->",
"open",
"(",
"$",
... | Unzip the web driver raw file.
@param $resource
@throws \ErrorException
@return $this | [
"Unzip",
"the",
"web",
"driver",
"raw",
"file",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Console/GetWebDriver.php#L109-L123 |
40,778 | Modelizer/Laravel-Selenium | src/Traits/WebDriverUtilsTrait.php | WebDriverUtilsTrait.setConfig | public function setConfig()
{
$this->config = (require static::prependPackagePath('bootstrap/config.php'))['web-drivers'];
$this->config = @$this->config[$this->getDriver()][$this->getUserOS()];
if (!$this->config) {
throw new \ErrorException("Currently {$this->getDriver()} not supported.");
}
return $this;
} | php | public function setConfig()
{
$this->config = (require static::prependPackagePath('bootstrap/config.php'))['web-drivers'];
$this->config = @$this->config[$this->getDriver()][$this->getUserOS()];
if (!$this->config) {
throw new \ErrorException("Currently {$this->getDriver()} not supported.");
}
return $this;
} | [
"public",
"function",
"setConfig",
"(",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"(",
"require",
"static",
"::",
"prependPackagePath",
"(",
"'bootstrap/config.php'",
")",
")",
"[",
"'web-drivers'",
"]",
";",
"$",
"this",
"->",
"config",
"=",
"@",
"$",
... | Set the configuration for web drivers.
@throws \ErrorException
@return $this | [
"Set",
"the",
"configuration",
"for",
"web",
"drivers",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Traits/WebDriverUtilsTrait.php#L92-L103 |
40,779 | Modelizer/Laravel-Selenium | src/Traits/WebDriverUtilsTrait.php | WebDriverUtilsTrait.prependPackagePath | public static function prependPackagePath($suffix, $assume = false)
{
$path = __DIR__."/../../$suffix";
if (!$assume and !$path) {
throw new \Exception("$path path does not exists.");
}
return $assume ? $path : realpath($path);
} | php | public static function prependPackagePath($suffix, $assume = false)
{
$path = __DIR__."/../../$suffix";
if (!$assume and !$path) {
throw new \Exception("$path path does not exists.");
}
return $assume ? $path : realpath($path);
} | [
"public",
"static",
"function",
"prependPackagePath",
"(",
"$",
"suffix",
",",
"$",
"assume",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"__DIR__",
".",
"\"/../../$suffix\"",
";",
"if",
"(",
"!",
"$",
"assume",
"and",
"!",
"$",
"path",
")",
"{",
"throw"... | Get the real path with package path prepended.
@param string $suffix suffix the file needed
@param bool $assume Possible directory can be created.
@throws \Exception
@return mixed | [
"Get",
"the",
"real",
"path",
"with",
"package",
"path",
"prepended",
"."
] | bbbcf802467cc10af17ff6edffb31440bab8ce11 | https://github.com/Modelizer/Laravel-Selenium/blob/bbbcf802467cc10af17ff6edffb31440bab8ce11/src/Traits/WebDriverUtilsTrait.php#L135-L144 |
40,780 | Maatwebsite/Laravel-Sidebar | src/Traits/CallableTrait.php | CallableTrait.call | public function call(Closure $callback = null, $caller = null)
{
if ($callback instanceof Closure) {
// Make dependency injection possible
$parameters = $this->resolveMethodDependencies(
[$caller], new ReflectionFunction($callback)
);
call_user_func_array($callback, $parameters);
}
return $caller;
} | php | public function call(Closure $callback = null, $caller = null)
{
if ($callback instanceof Closure) {
// Make dependency injection possible
$parameters = $this->resolveMethodDependencies(
[$caller], new ReflectionFunction($callback)
);
call_user_func_array($callback, $parameters);
}
return $caller;
} | [
"public",
"function",
"call",
"(",
"Closure",
"$",
"callback",
"=",
"null",
",",
"$",
"caller",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"callback",
"instanceof",
"Closure",
")",
"{",
"// Make dependency injection possible",
"$",
"parameters",
"=",
"$",
"this"... | Preform a callback on this workbook instance.
@param callable $callback
@param null $caller
@return $this | [
"Preform",
"a",
"callback",
"on",
"this",
"workbook",
"instance",
"."
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/Traits/CallableTrait.php#L21-L32 |
40,781 | Maatwebsite/Laravel-Sidebar | src/Domain/DefaultMenu.php | DefaultMenu.group | public function group($name, Closure $callback = null)
{
if ($this->groups->has($name)) {
$group = $this->groups->get($name);
} else {
$group = $this->container->make('Maatwebsite\Sidebar\Group');
$group->name($name);
}
$this->call($callback, $group);
$this->addGroup($group);
return $group;
} | php | public function group($name, Closure $callback = null)
{
if ($this->groups->has($name)) {
$group = $this->groups->get($name);
} else {
$group = $this->container->make('Maatwebsite\Sidebar\Group');
$group->name($name);
}
$this->call($callback, $group);
$this->addGroup($group);
return $group;
} | [
"public",
"function",
"group",
"(",
"$",
"name",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"groups",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"groups",
"->",
... | Init a new group or call an existing group and add it to the menu
@param $name
@param callable $callback
@return Group | [
"Init",
"a",
"new",
"group",
"or",
"call",
"an",
"existing",
"group",
"and",
"add",
"it",
"to",
"the",
"menu"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/Domain/DefaultMenu.php#L54-L68 |
40,782 | Maatwebsite/Laravel-Sidebar | src/Domain/DefaultMenu.php | DefaultMenu.addGroup | public function addGroup(Group $group)
{
$this->groups->put($group->getName(), $group);
return $this;
} | php | public function addGroup(Group $group)
{
$this->groups->put($group->getName(), $group);
return $this;
} | [
"public",
"function",
"addGroup",
"(",
"Group",
"$",
"group",
")",
"{",
"$",
"this",
"->",
"groups",
"->",
"put",
"(",
"$",
"group",
"->",
"getName",
"(",
")",
",",
"$",
"group",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a Group instance to the Menu
@param Group $group
@return $this | [
"Add",
"a",
"Group",
"instance",
"to",
"the",
"Menu"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/Domain/DefaultMenu.php#L77-L82 |
40,783 | Maatwebsite/Laravel-Sidebar | src/Domain/DefaultMenu.php | DefaultMenu.add | public function add(Menu $menu)
{
foreach ($menu->getGroups() as $group) {
if ($this->groups->has($group->getName())) {
$existingGroup = $this->groups->get($group->getName());
$group->hideHeading(!$group->shouldShowHeading());
foreach ($group->getItems() as $item) {
$existingGroup->addItem($item);
}
} else {
$this->addGroup($group);
}
}
return $this;
} | php | public function add(Menu $menu)
{
foreach ($menu->getGroups() as $group) {
if ($this->groups->has($group->getName())) {
$existingGroup = $this->groups->get($group->getName());
$group->hideHeading(!$group->shouldShowHeading());
foreach ($group->getItems() as $item) {
$existingGroup->addItem($item);
}
} else {
$this->addGroup($group);
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"Menu",
"$",
"menu",
")",
"{",
"foreach",
"(",
"$",
"menu",
"->",
"getGroups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"groups",
"->",
"has",
"(",
"$",
"group",
"->",
"getName",
"(",... | Add another Menu instance and combined the two
Groups with the same name get combined, but
inherit each other's items
@param Menu $menu
@return Menu $menu | [
"Add",
"another",
"Menu",
"instance",
"and",
"combined",
"the",
"two",
"Groups",
"with",
"the",
"same",
"name",
"get",
"combined",
"but",
"inherit",
"each",
"other",
"s",
"items"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/Domain/DefaultMenu.php#L104-L121 |
40,784 | Maatwebsite/Laravel-Sidebar | src/SidebarManager.php | SidebarManager.register | public function register($name)
{
if (class_exists($name)) {
$this->sidebars[] = $name;
} else {
throw new LogicException('Sidebar [' . $name . '] does not exist');
}
return $this;
} | php | public function register($name)
{
if (class_exists($name)) {
$this->sidebars[] = $name;
} else {
throw new LogicException('Sidebar [' . $name . '] does not exist');
}
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"sidebars",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"else",
"{",
"throw",
"new",
"LogicException",
"(",
"'Sid... | Register the sidebar
@param $name
@throws LogicException
@return $this | [
"Register",
"the",
"sidebar"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/SidebarManager.php#L45-L54 |
40,785 | Maatwebsite/Laravel-Sidebar | src/SidebarManager.php | SidebarManager.resolve | public function resolve()
{
foreach ($this->sidebars as $name) {
$sidebar = $this->resolver->resolve($name);
$this->container->singleton($name, function () use ($sidebar) {
return $sidebar;
});
}
} | php | public function resolve()
{
foreach ($this->sidebars as $name) {
$sidebar = $this->resolver->resolve($name);
$this->container->singleton($name, function () use ($sidebar) {
return $sidebar;
});
}
} | [
"public",
"function",
"resolve",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sidebars",
"as",
"$",
"name",
")",
"{",
"$",
"sidebar",
"=",
"$",
"this",
"->",
"resolver",
"->",
"resolve",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"contain... | Bind sidebar instances to the ioC | [
"Bind",
"sidebar",
"instances",
"to",
"the",
"ioC"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/SidebarManager.php#L59-L68 |
40,786 | Maatwebsite/Laravel-Sidebar | src/Traits/ItemableTrait.php | ItemableTrait.addItem | public function addItem(Item $item)
{
$this->items->put($item->getName(), $item);
return $this;
} | php | public function addItem(Item $item)
{
$this->items->put($item->getName(), $item);
return $this;
} | [
"public",
"function",
"addItem",
"(",
"Item",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"items",
"->",
"put",
"(",
"$",
"item",
"->",
"getName",
"(",
")",
",",
"$",
"item",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add Item instance to Group
@param Item $item
@return Item | [
"Add",
"Item",
"instance",
"to",
"Group"
] | 77b14cb48ac9fce45fffd6825c999fe154e70137 | https://github.com/Maatwebsite/Laravel-Sidebar/blob/77b14cb48ac9fce45fffd6825c999fe154e70137/src/Traits/ItemableTrait.php#L47-L52 |
40,787 | Eden-PHP/Core | src/Exception.php | Exception.trigger | public function trigger()
{
$this->trace = debug_backtrace();
$this->reporter = get_class($this);
if (isset($this->trace[$this->offset]['class'])) {
$this->reporter = $this->trace[$this->offset]['class'];
}
if (isset($this->trace[$this->offset]['file'])) {
$this->file = $this->trace[$this->offset]['file'];
}
if (isset($this->trace[$this->offset]['line'])) {
$this->line = $this->trace[$this->offset]['line'];
}
if (!empty($this->variables)) {
$this->message = vsprintf($this->message, $this->variables);
$this->variables = array();
}
throw $this;
} | php | public function trigger()
{
$this->trace = debug_backtrace();
$this->reporter = get_class($this);
if (isset($this->trace[$this->offset]['class'])) {
$this->reporter = $this->trace[$this->offset]['class'];
}
if (isset($this->trace[$this->offset]['file'])) {
$this->file = $this->trace[$this->offset]['file'];
}
if (isset($this->trace[$this->offset]['line'])) {
$this->line = $this->trace[$this->offset]['line'];
}
if (!empty($this->variables)) {
$this->message = vsprintf($this->message, $this->variables);
$this->variables = array();
}
throw $this;
} | [
"public",
"function",
"trigger",
"(",
")",
"{",
"$",
"this",
"->",
"trace",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"this",
"->",
"reporter",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"trace",
"["... | Combines parameters with message and throws it | [
"Combines",
"parameters",
"with",
"message",
"and",
"throws",
"it"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Exception.php#L326-L349 |
40,788 | Eden-PHP/Core | src/Route.php | Route.get | public function get($route = null)
{
//argument 1 must be a string or null
Argument::i()->test(1, 'string', 'null');
//if route is null
if (is_null($route)) {
//return all routes
return $this->route;
}
//if valid route
if ($this->valid($route)) {
//return route
return $this->route[strtolower($route)];
}
//at this point it is not a route
//return the same thing
return $route;
} | php | public function get($route = null)
{
//argument 1 must be a string or null
Argument::i()->test(1, 'string', 'null');
//if route is null
if (is_null($route)) {
//return all routes
return $this->route;
}
//if valid route
if ($this->valid($route)) {
//return route
return $this->route[strtolower($route)];
}
//at this point it is not a route
//return the same thing
return $route;
} | [
"public",
"function",
"get",
"(",
"$",
"route",
"=",
"null",
")",
"{",
"//argument 1 must be a string or null",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
",",
"'null'",
")",
";",
"//if route is null",
"if",
"(",
"is_null",
"... | Returns the class that will be routed to given the route.
@param string|null $route the class route name
@return string|object|array | [
"Returns",
"the",
"class",
"that",
"will",
"be",
"routed",
"to",
"given",
"the",
"route",
"."
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Route.php#L116-L136 |
40,789 | Eden-PHP/Core | src/Route.php | Route.valid | public function valid($route)
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
return isset($this->route[strtolower($route)]);
} | php | public function valid($route)
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
return isset($this->route[strtolower($route)]);
} | [
"public",
"function",
"valid",
"(",
"$",
"route",
")",
"{",
"//argument 1 must be a string",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"route",
"[",
"strtolower",
"(",
... | Checks to see if a name is a route
@param *string $route the class route name
@return bool | [
"Checks",
"to",
"see",
"if",
"a",
"name",
"is",
"a",
"route"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Route.php#L145-L151 |
40,790 | Eden-PHP/Core | src/Route.php | Route.release | public function release($route)
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
if ($this->valid($route)) {
unset($this->route[strtolower($route)]);
}
return $this;
} | php | public function release($route)
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
if ($this->valid($route)) {
unset($this->route[strtolower($route)]);
}
return $this;
} | [
"public",
"function",
"release",
"(",
"$",
"route",
")",
"{",
"//argument 1 must be a string",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
"$",
"route",
")",
")",
"{"... | Unsets the route
@param *string $route the class route name
@return Eden\Core\Route | [
"Unsets",
"the",
"route"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Route.php#L160-L170 |
40,791 | Eden-PHP/Core | src/Route.php | Route.set | public function set($source, $destination)
{
//argument test
Argument::i()
//argument 1 must be a string or object
->test(1, 'string', 'object')
//argument 2 must be a string or object
->test(2, 'string', 'object');
//if source is an object
if (is_object($source)) {
//transform it into string class
$source = get_class($source);
}
//if it is a string
if (is_string($destination)) {
//we need to consider if this is a vitual class
$destination = $this->get($destination);
}
//now let's route it
$this->route[strtolower($source)] = $destination;
return $this;
} | php | public function set($source, $destination)
{
//argument test
Argument::i()
//argument 1 must be a string or object
->test(1, 'string', 'object')
//argument 2 must be a string or object
->test(2, 'string', 'object');
//if source is an object
if (is_object($source)) {
//transform it into string class
$source = get_class($source);
}
//if it is a string
if (is_string($destination)) {
//we need to consider if this is a vitual class
$destination = $this->get($destination);
}
//now let's route it
$this->route[strtolower($source)] = $destination;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"//argument test",
"Argument",
"::",
"i",
"(",
")",
"//argument 1 must be a string or object",
"->",
"test",
"(",
"1",
",",
"'string'",
",",
"'object'",
")",
"//argument 2 must b... | Routes a class
@param *string $source the class route name
@param *string $destination the name of the class to route to
@return Eden\Core\Route | [
"Routes",
"a",
"class"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Route.php#L180-L205 |
40,792 | Eden-PHP/Core | src/Argument.php | Argument.virtual | public function virtual($method, array $args, $index, $types)
{
//if no test
if (static::$stop) {
return $this;
}
$offset = 1;
//if the trace came from Argument->test()
if (isset($trace['class'], $trace['function'])
&& $trace['class'] == __CLASS__
&& $trace['function'] == 'test'
) {
//go back one more
$offset = 2;
}
$trace = debug_backtrace();
$trace = $trace[$offset];
$types = func_get_args();
$method = array_shift($types);
$args = array_shift($types);
$index = array_shift($types) - 1;
if ($index < 0) {
$index = 0;
}
//if it's not set then it's good because the default value
//set in the method will be it.
if ($index >= count($args)) {
return $this;
}
$argument = $args[$index];
foreach ($types as $i => $type) {
if ($this->isValid($type, $argument)) {
return $this;
}
}
if (strpos($method, '->') === false && isset($trace['class'])) {
$method = $trace['class'].'->'.$method;
}
$type = $this->getDataType($argument);
Exception::i()
->setMessage(self::INVALID_ARGUMENT)
->addVariable($index + 1)
->addVariable($method)
->addVariable(implode(' or ', $types))
->addVariable($type)
->setTypeLogic()
->setTraceOffset($offset)
->trigger();
} | php | public function virtual($method, array $args, $index, $types)
{
//if no test
if (static::$stop) {
return $this;
}
$offset = 1;
//if the trace came from Argument->test()
if (isset($trace['class'], $trace['function'])
&& $trace['class'] == __CLASS__
&& $trace['function'] == 'test'
) {
//go back one more
$offset = 2;
}
$trace = debug_backtrace();
$trace = $trace[$offset];
$types = func_get_args();
$method = array_shift($types);
$args = array_shift($types);
$index = array_shift($types) - 1;
if ($index < 0) {
$index = 0;
}
//if it's not set then it's good because the default value
//set in the method will be it.
if ($index >= count($args)) {
return $this;
}
$argument = $args[$index];
foreach ($types as $i => $type) {
if ($this->isValid($type, $argument)) {
return $this;
}
}
if (strpos($method, '->') === false && isset($trace['class'])) {
$method = $trace['class'].'->'.$method;
}
$type = $this->getDataType($argument);
Exception::i()
->setMessage(self::INVALID_ARGUMENT)
->addVariable($index + 1)
->addVariable($method)
->addVariable(implode(' or ', $types))
->addVariable($type)
->setTypeLogic()
->setTraceOffset($offset)
->trigger();
} | [
"public",
"function",
"virtual",
"(",
"$",
"method",
",",
"array",
"$",
"args",
",",
"$",
"index",
",",
"$",
"types",
")",
"{",
"//if no test",
"if",
"(",
"static",
"::",
"$",
"stop",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"offset",
"=",
... | Tests virtual arguments for valid data types
@param *string $method method name
@param *array $args arguments
@param *int $index the argument index to test for
@param *mixed[,mixed..] $types the types to test for
@return Eden\Core\Argument | [
"Tests",
"virtual",
"arguments",
"for",
"valid",
"data",
"types"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Argument.php#L122-L181 |
40,793 | Eden-PHP/Core | src/Argument.php | Argument.getDataType | private function getDataType($data)
{
if (is_string($data)) {
return "'".$data."'";
}
if (is_numeric($data)) {
return $data;
}
if (is_array($data)) {
return 'Array';
}
if (is_bool($data)) {
return $data ? 'true' : 'false';
}
if (is_object($data)) {
return get_class($data);
}
if (is_null($data)) {
return 'null';
}
return 'unknown';
} | php | private function getDataType($data)
{
if (is_string($data)) {
return "'".$data."'";
}
if (is_numeric($data)) {
return $data;
}
if (is_array($data)) {
return 'Array';
}
if (is_bool($data)) {
return $data ? 'true' : 'false';
}
if (is_object($data)) {
return get_class($data);
}
if (is_null($data)) {
return 'null';
}
return 'unknown';
} | [
"private",
"function",
"getDataType",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"return",
"\"'\"",
".",
"$",
"data",
".",
"\"'\"",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"data",
")",
")",
"{",
"ret... | Returns the data type of the argument
@param *mixed $data the value being tested
@return string | [
"Returns",
"the",
"data",
"type",
"of",
"the",
"argument"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Argument.php#L378-L405 |
40,794 | Eden-PHP/Core | src/Base.php | Base.addMethod | public function addMethod($source, $destination = null)
{
//argument test
Argument::i()
//argument 1 must be a string
->test(1, 'string')
//argument 2 must be callable or null
->test(2, 'callable', 'null');
if (is_null($destination)) {
//when someone calls a class call this instead
Route::i()->set($source, $this);
return $this;
}
//if it's an array they meant to bind the callback
if (!is_array($destination)) {
//so there's no scope
$destination = $destination->bindTo($this, get_class($this));
}
//store it
self::$invokables[$source] = $destination;
return $this;
} | php | public function addMethod($source, $destination = null)
{
//argument test
Argument::i()
//argument 1 must be a string
->test(1, 'string')
//argument 2 must be callable or null
->test(2, 'callable', 'null');
if (is_null($destination)) {
//when someone calls a class call this instead
Route::i()->set($source, $this);
return $this;
}
//if it's an array they meant to bind the callback
if (!is_array($destination)) {
//so there's no scope
$destination = $destination->bindTo($this, get_class($this));
}
//store it
self::$invokables[$source] = $destination;
return $this;
} | [
"public",
"function",
"addMethod",
"(",
"$",
"source",
",",
"$",
"destination",
"=",
"null",
")",
"{",
"//argument test",
"Argument",
"::",
"i",
"(",
")",
"//argument 1 must be a string",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
"//argument 2 must be callab... | Creates a class route for this class.
@param *string $source the class route name
@param callable|null $desination callback handler
@return Eden\Core\Base | [
"Creates",
"a",
"class",
"route",
"for",
"this",
"class",
"."
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Base.php#L268-L293 |
40,795 | Eden-PHP/Core | src/Base.php | Base.callArray | public function callArray($method, array $args = array())
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
return call_user_func_array(array($this, $method), $args);
} | php | public function callArray($method, array $args = array())
{
//argument 1 must be a string
Argument::i()->test(1, 'string');
return call_user_func_array(array($this, $method), $args);
} | [
"public",
"function",
"callArray",
"(",
"$",
"method",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"//argument 1 must be a string",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
";",
"return",
"call_user_... | Calls a method in this class and allows
arguments to be passed as an array
@param *string $method method name
@param array $args arguments
@return mixed | [
"Calls",
"a",
"method",
"in",
"this",
"class",
"and",
"allows",
"arguments",
"to",
"be",
"passed",
"as",
"an",
"array"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Base.php#L304-L310 |
40,796 | Eden-PHP/Core | src/Base.php | Base.getMultiple | protected static function getMultiple($class = null)
{
//super magic sauce getting the callers class
if (is_null($class) && function_exists('get_called_class')) {
$class = get_called_class();
}
//get routed class, if any
$class = Route::i()->get($class);
return self::getInstance($class);
} | php | protected static function getMultiple($class = null)
{
//super magic sauce getting the callers class
if (is_null($class) && function_exists('get_called_class')) {
$class = get_called_class();
}
//get routed class, if any
$class = Route::i()->get($class);
return self::getInstance($class);
} | [
"protected",
"static",
"function",
"getMultiple",
"(",
"$",
"class",
"=",
"null",
")",
"{",
"//super magic sauce getting the callers class",
"if",
"(",
"is_null",
"(",
"$",
"class",
")",
"&&",
"function_exists",
"(",
"'get_called_class'",
")",
")",
"{",
"$",
"cl... | Returns a non-singleton class, while considering routes
@param string|null $class name of the class
@return object | [
"Returns",
"a",
"non",
"-",
"singleton",
"class",
"while",
"considering",
"routes"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Base.php#L570-L580 |
40,797 | Eden-PHP/Core | src/Base.php | Base.getSingleton | protected static function getSingleton($class = null)
{
//super magic sauce getting the callers class
if (is_null($class) && function_exists('get_called_class')) {
$class = get_called_class();
}
//get routed class, if any
$class = Route::i()->get($class);
//if it's not set
if (!isset(self::$instances[$class])) {
//set it
self::$instances[$class] = self::getInstance($class);
}
//return the cached version
return self::$instances[$class];
} | php | protected static function getSingleton($class = null)
{
//super magic sauce getting the callers class
if (is_null($class) && function_exists('get_called_class')) {
$class = get_called_class();
}
//get routed class, if any
$class = Route::i()->get($class);
//if it's not set
if (!isset(self::$instances[$class])) {
//set it
self::$instances[$class] = self::getInstance($class);
}
//return the cached version
return self::$instances[$class];
} | [
"protected",
"static",
"function",
"getSingleton",
"(",
"$",
"class",
"=",
"null",
")",
"{",
"//super magic sauce getting the callers class",
"if",
"(",
"is_null",
"(",
"$",
"class",
")",
"&&",
"function_exists",
"(",
"'get_called_class'",
")",
")",
"{",
"$",
"c... | Returns the same instance if instantiated already
while considering routes.
@param string|null $class name of the class
@return object | [
"Returns",
"the",
"same",
"instance",
"if",
"instantiated",
"already",
"while",
"considering",
"routes",
"."
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Base.php#L590-L608 |
40,798 | Eden-PHP/Core | src/Base.php | Base.getInstance | private static function getInstance($class)
{
//get the backtrace
$trace = debug_backtrace();
$args = array();
//the 2nd line is the caller method
if (isset($trace[1]['args']) && count($trace[1]['args']) > 1) {
//get the args
$args = $trace[1]['args'];
//shift out the class name
array_shift($args);
//then maybe it's the 3rd line?
} else if (isset($trace[2]['args']) && count($trace[2]['args']) > 0) {
//get the args
$args = $trace[2]['args'];
}
//if there's no args or there's no construct to accept the args
if (count($args) === 0 || !method_exists($class, '__construct')) {
//just return the instantiation
return new $class;
}
//at this point, we need to vitually call the class
$reflect = new \ReflectionClass($class);
try { //to return the instantiation
return $reflect->newInstanceArgs($args);
} catch (\ReflectionException $e) {
//trigger error
Exception::i()
->setMessage(self::ERROR_REFLECTION)
->addVariable($class)
->addVariable('new')
->trigger();
}
} | php | private static function getInstance($class)
{
//get the backtrace
$trace = debug_backtrace();
$args = array();
//the 2nd line is the caller method
if (isset($trace[1]['args']) && count($trace[1]['args']) > 1) {
//get the args
$args = $trace[1]['args'];
//shift out the class name
array_shift($args);
//then maybe it's the 3rd line?
} else if (isset($trace[2]['args']) && count($trace[2]['args']) > 0) {
//get the args
$args = $trace[2]['args'];
}
//if there's no args or there's no construct to accept the args
if (count($args) === 0 || !method_exists($class, '__construct')) {
//just return the instantiation
return new $class;
}
//at this point, we need to vitually call the class
$reflect = new \ReflectionClass($class);
try { //to return the instantiation
return $reflect->newInstanceArgs($args);
} catch (\ReflectionException $e) {
//trigger error
Exception::i()
->setMessage(self::ERROR_REFLECTION)
->addVariable($class)
->addVariable('new')
->trigger();
}
} | [
"private",
"static",
"function",
"getInstance",
"(",
"$",
"class",
")",
"{",
"//get the backtrace",
"$",
"trace",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"//the 2nd line is the caller method",
"if",
"(",
"isset",
"(",
... | Returns an instance considering routes. With
this method we can instantiate while passing
construct arguments as arrays
@param *string $class name of the class
@return object | [
"Returns",
"an",
"instance",
"considering",
"routes",
".",
"With",
"this",
"method",
"we",
"can",
"instantiate",
"while",
"passing",
"construct",
"arguments",
"as",
"arrays"
] | 2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72 | https://github.com/Eden-PHP/Core/blob/2dbd1f3e83ca0dd2d787d31f1654335fba6b6f72/src/Base.php#L619-L656 |
40,799 | dapphp/radius | src/EAPPacket.php | EAPPacket.identity | public static function identity($identity, $id = null)
{
$packet = new self();
$packet->setId($id);
$packet->code = self::CODE_RESPONSE;
$packet->type = self::TYPE_IDENTITY;
$packet->data = $identity;
return $packet->__toString();
} | php | public static function identity($identity, $id = null)
{
$packet = new self();
$packet->setId($id);
$packet->code = self::CODE_RESPONSE;
$packet->type = self::TYPE_IDENTITY;
$packet->data = $identity;
return $packet->__toString();
} | [
"public",
"static",
"function",
"identity",
"(",
"$",
"identity",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"packet",
"=",
"new",
"self",
"(",
")",
";",
"$",
"packet",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"$",
"packet",
"->",
"code",
"=",
... | Helper function to generate an EAP Identity packet
@param string $identity The identity (username) to send in the packet
@param int $id The packet ID (random if omitted)
@return string An EAP identity packet | [
"Helper",
"function",
"to",
"generate",
"an",
"EAP",
"Identity",
"packet"
] | 1954c34cd67f8a581b0a4c77241f472db0ef8199 | https://github.com/dapphp/radius/blob/1954c34cd67f8a581b0a4c77241f472db0ef8199/src/EAPPacket.php#L36-L45 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.