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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Linkvalue-Interne/MajoraFrameworkExtraBundle
src/Majora/Framework/Loader/Bridge/Doctrine/DoctrineEventProxy.php
DoctrineEventProxy.registerDoctrineLazyLoader
public function registerDoctrineLazyLoader($entityClass, LazyLoaderInterface $loader) { if (!is_a($entityClass, LazyPropertiesInterface::class, true)) { throw new \InvalidArgumentException(sprintf( 'Class %s has to implement %s to be able to lazy load her properties.', $entityClass, LazyPropertiesInterface::class )); } $this->loaders->set($entityClass, $loader); }
php
public function registerDoctrineLazyLoader($entityClass, LazyLoaderInterface $loader) { if (!is_a($entityClass, LazyPropertiesInterface::class, true)) { throw new \InvalidArgumentException(sprintf( 'Class %s has to implement %s to be able to lazy load her properties.', $entityClass, LazyPropertiesInterface::class )); } $this->loaders->set($entityClass, $loader); }
[ "public", "function", "registerDoctrineLazyLoader", "(", "$", "entityClass", ",", "LazyLoaderInterface", "$", "loader", ")", "{", "if", "(", "!", "is_a", "(", "$", "entityClass", ",", "LazyPropertiesInterface", "::", "class", ",", "true", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Class %s has to implement %s to be able to lazy load her properties.'", ",", "$", "entityClass", ",", "LazyPropertiesInterface", "::", "class", ")", ")", ";", "}", "$", "this", "->", "loaders", "->", "set", "(", "$", "entityClass", ",", "$", "loader", ")", ";", "}" ]
Register a loader for given entity class. @param string $entityClass @param string $loader
[ "Register", "a", "loader", "for", "given", "entity", "class", "." ]
6f368380cfc39d27fafb0844e9a53b4d86d7c034
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Loader/Bridge/Doctrine/DoctrineEventProxy.php#L41-L52
train
Linkvalue-Interne/MajoraFrameworkExtraBundle
src/Majora/Framework/Loader/Bridge/Doctrine/DoctrineEventProxy.php
DoctrineEventProxy.postLoad
public function postLoad(LifecycleEventArgs $event) { if (!$loader = $this->getLoader($entity = $event->getEntity())) { return; } // global handler (deprecated) if (isset($proxies[$loaderClass = static::class])) { @trigger_error( sprintf('Global loader delegate is deprecated and will be removed in 2.0. Make "%s" loader invokable instead, entity to handle is given at first parameter.', static::class ), E_USER_DEPRECATED ); $proxies[$loaderClass]($entity); unset($proxies[$loaderClass]); } // define delegates into object $entity->registerLoaders( $loader->getLoadingDelegates() ); // global delegate if able to if (is_callable($loader)) { $loader($entity); } }
php
public function postLoad(LifecycleEventArgs $event) { if (!$loader = $this->getLoader($entity = $event->getEntity())) { return; } // global handler (deprecated) if (isset($proxies[$loaderClass = static::class])) { @trigger_error( sprintf('Global loader delegate is deprecated and will be removed in 2.0. Make "%s" loader invokable instead, entity to handle is given at first parameter.', static::class ), E_USER_DEPRECATED ); $proxies[$loaderClass]($entity); unset($proxies[$loaderClass]); } // define delegates into object $entity->registerLoaders( $loader->getLoadingDelegates() ); // global delegate if able to if (is_callable($loader)) { $loader($entity); } }
[ "public", "function", "postLoad", "(", "LifecycleEventArgs", "$", "event", ")", "{", "if", "(", "!", "$", "loader", "=", "$", "this", "->", "getLoader", "(", "$", "entity", "=", "$", "event", "->", "getEntity", "(", ")", ")", ")", "{", "return", ";", "}", "// global handler (deprecated)", "if", "(", "isset", "(", "$", "proxies", "[", "$", "loaderClass", "=", "static", "::", "class", "]", ")", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'Global loader delegate is deprecated and will be removed in 2.0. Make \"%s\" loader invokable instead, entity to handle is given at first parameter.'", ",", "static", "::", "class", ")", ",", "E_USER_DEPRECATED", ")", ";", "$", "proxies", "[", "$", "loaderClass", "]", "(", "$", "entity", ")", ";", "unset", "(", "$", "proxies", "[", "$", "loaderClass", "]", ")", ";", "}", "// define delegates into object", "$", "entity", "->", "registerLoaders", "(", "$", "loader", "->", "getLoadingDelegates", "(", ")", ")", ";", "// global delegate if able to", "if", "(", "is_callable", "(", "$", "loader", ")", ")", "{", "$", "loader", "(", "$", "entity", ")", ";", "}", "}" ]
"postLoad" Doctrine event handler, notify loaders if define for given event related entity. @param LifecycleEventArgs $event
[ "postLoad", "Doctrine", "event", "handler", "notify", "loaders", "if", "define", "for", "given", "event", "related", "entity", "." ]
6f368380cfc39d27fafb0844e9a53b4d86d7c034
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Loader/Bridge/Doctrine/DoctrineEventProxy.php#L87-L114
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Persisters.php
Persisters.createConnection
private function createConnection(array $persisterConfig, $configName) { $options = isset($persisterConfig['parameters']['options']) && is_array($persisterConfig['parameters']['options']) ? $persisterConfig['parameters']['options'] : []; $definition = new Definition( 'Doctrine\MongoDB\Connection', [$persisterConfig['parameters']['host'], $options, new Reference($configName)] ); $definition->setPublic(false); return $definition; }
php
private function createConnection(array $persisterConfig, $configName) { $options = isset($persisterConfig['parameters']['options']) && is_array($persisterConfig['parameters']['options']) ? $persisterConfig['parameters']['options'] : []; $definition = new Definition( 'Doctrine\MongoDB\Connection', [$persisterConfig['parameters']['host'], $options, new Reference($configName)] ); $definition->setPublic(false); return $definition; }
[ "private", "function", "createConnection", "(", "array", "$", "persisterConfig", ",", "$", "configName", ")", "{", "$", "options", "=", "isset", "(", "$", "persisterConfig", "[", "'parameters'", "]", "[", "'options'", "]", ")", "&&", "is_array", "(", "$", "persisterConfig", "[", "'parameters'", "]", "[", "'options'", "]", ")", "?", "$", "persisterConfig", "[", "'parameters'", "]", "[", "'options'", "]", ":", "[", "]", ";", "$", "definition", "=", "new", "Definition", "(", "'Doctrine\\MongoDB\\Connection'", ",", "[", "$", "persisterConfig", "[", "'parameters'", "]", "[", "'host'", "]", ",", "$", "options", ",", "new", "Reference", "(", "$", "configName", ")", "]", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "return", "$", "definition", ";", "}" ]
Creates the connection service definition. @param array $persisterConfig @param string $configName The name of the connection configuration service @return Definition
[ "Creates", "the", "connection", "service", "definition", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Persisters.php#L52-L61
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Persisters.php
Persisters.createDataCollector
private function createDataCollector() { $definition = new Definition( Utility::getBundleClass('DataCollector\MongoDb\PrettyDataCollector') ); $definition->addTag('data_collector', ['id' => 'as3persistermongodb', 'template' => 'As3ModlrBundle:Collector:mongodb']); $definition->setPublic(false); return $definition; }
php
private function createDataCollector() { $definition = new Definition( Utility::getBundleClass('DataCollector\MongoDb\PrettyDataCollector') ); $definition->addTag('data_collector', ['id' => 'as3persistermongodb', 'template' => 'As3ModlrBundle:Collector:mongodb']); $definition->setPublic(false); return $definition; }
[ "private", "function", "createDataCollector", "(", ")", "{", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getBundleClass", "(", "'DataCollector\\MongoDb\\PrettyDataCollector'", ")", ")", ";", "$", "definition", "->", "addTag", "(", "'data_collector'", ",", "[", "'id'", "=>", "'as3persistermongodb'", ",", "'template'", "=>", "'As3ModlrBundle:Collector:mongodb'", "]", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "return", "$", "definition", ";", "}" ]
Creates the persistence data collector service definition. @return Definition
[ "Creates", "the", "persistence", "data", "collector", "service", "definition", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Persisters.php#L100-L108
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Persisters.php
Persisters.createMongoDbPersister
private function createMongoDbPersister($persisterName, array $persisterConfig, ContainerBuilder $container) { // Storage metadata $smfName = sprintf('%s.metadata', $persisterName); $definition = $this->createSmf(); $container->setDefinition($smfName, $definition); // Configuration $configName = sprintf('%s.configuration', $persisterName); $definition = $this->createConfiguration($persisterName, $persisterConfig, $container); $container->setDefinition($configName, $definition); // Connection $conName = sprintf('%s.connection', $persisterName); $definition = $this->createConnection($persisterConfig, $configName); $container->setDefinition($conName, $definition); // Formatter $formatterName = sprintf('%s.formatter', $persisterName); $definition = $this->createFormatter(); $container->setDefinition($formatterName, $definition); // Query $queryName = sprintf('%s.query', $persisterName); $definition = $this->createQuery($conName, $formatterName); $container->setDefinition($queryName, $definition); // Hydrator $hydratorName = sprintf('%s.hydrator', $persisterName); $definition = $this->createHydrator(); $container->setDefinition($hydratorName, $definition); // Schema Manager $schemaManagerName = sprintf('%s.schema_manager', $persisterName); $definition = $this->createSchemaManager(); $container->setDefinition($schemaManagerName, $definition); // Persister return new Definition( Utility::getLibraryClass('Persister\MongoDb\Persister'), [new Reference($queryName), new Reference($smfName), new Reference($hydratorName), new Reference($schemaManagerName)] ); }
php
private function createMongoDbPersister($persisterName, array $persisterConfig, ContainerBuilder $container) { // Storage metadata $smfName = sprintf('%s.metadata', $persisterName); $definition = $this->createSmf(); $container->setDefinition($smfName, $definition); // Configuration $configName = sprintf('%s.configuration', $persisterName); $definition = $this->createConfiguration($persisterName, $persisterConfig, $container); $container->setDefinition($configName, $definition); // Connection $conName = sprintf('%s.connection', $persisterName); $definition = $this->createConnection($persisterConfig, $configName); $container->setDefinition($conName, $definition); // Formatter $formatterName = sprintf('%s.formatter', $persisterName); $definition = $this->createFormatter(); $container->setDefinition($formatterName, $definition); // Query $queryName = sprintf('%s.query', $persisterName); $definition = $this->createQuery($conName, $formatterName); $container->setDefinition($queryName, $definition); // Hydrator $hydratorName = sprintf('%s.hydrator', $persisterName); $definition = $this->createHydrator(); $container->setDefinition($hydratorName, $definition); // Schema Manager $schemaManagerName = sprintf('%s.schema_manager', $persisterName); $definition = $this->createSchemaManager(); $container->setDefinition($schemaManagerName, $definition); // Persister return new Definition( Utility::getLibraryClass('Persister\MongoDb\Persister'), [new Reference($queryName), new Reference($smfName), new Reference($hydratorName), new Reference($schemaManagerName)] ); }
[ "private", "function", "createMongoDbPersister", "(", "$", "persisterName", ",", "array", "$", "persisterConfig", ",", "ContainerBuilder", "$", "container", ")", "{", "// Storage metadata", "$", "smfName", "=", "sprintf", "(", "'%s.metadata'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createSmf", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "smfName", ",", "$", "definition", ")", ";", "// Configuration", "$", "configName", "=", "sprintf", "(", "'%s.configuration'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createConfiguration", "(", "$", "persisterName", ",", "$", "persisterConfig", ",", "$", "container", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "configName", ",", "$", "definition", ")", ";", "// Connection", "$", "conName", "=", "sprintf", "(", "'%s.connection'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createConnection", "(", "$", "persisterConfig", ",", "$", "configName", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "conName", ",", "$", "definition", ")", ";", "// Formatter", "$", "formatterName", "=", "sprintf", "(", "'%s.formatter'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createFormatter", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "formatterName", ",", "$", "definition", ")", ";", "// Query", "$", "queryName", "=", "sprintf", "(", "'%s.query'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createQuery", "(", "$", "conName", ",", "$", "formatterName", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "queryName", ",", "$", "definition", ")", ";", "// Hydrator", "$", "hydratorName", "=", "sprintf", "(", "'%s.hydrator'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createHydrator", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "hydratorName", ",", "$", "definition", ")", ";", "// Schema Manager", "$", "schemaManagerName", "=", "sprintf", "(", "'%s.schema_manager'", ",", "$", "persisterName", ")", ";", "$", "definition", "=", "$", "this", "->", "createSchemaManager", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "schemaManagerName", ",", "$", "definition", ")", ";", "// Persister", "return", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Persister\\MongoDb\\Persister'", ")", ",", "[", "new", "Reference", "(", "$", "queryName", ")", ",", "new", "Reference", "(", "$", "smfName", ")", ",", "new", "Reference", "(", "$", "hydratorName", ")", ",", "new", "Reference", "(", "$", "schemaManagerName", ")", "]", ")", ";", "}" ]
Creates the MongoDB persister service definition. Will also load support services. @param string $persisterName @param array $persisterConfig @param ContainerBuilder $container @return Definition
[ "Creates", "the", "MongoDB", "persister", "service", "definition", ".", "Will", "also", "load", "support", "services", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Persisters.php#L147-L189
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Persisters.php
Persisters.createSmf
private function createSmf() { $definition = new Definition( Utility::getLibraryClass('Persister\MongoDb\StorageMetadataFactory'), [new Reference(Utility::getAliasedName('util.entity'))] ); $definition->setPublic(false); return $definition; }
php
private function createSmf() { $definition = new Definition( Utility::getLibraryClass('Persister\MongoDb\StorageMetadataFactory'), [new Reference(Utility::getAliasedName('util.entity'))] ); $definition->setPublic(false); return $definition; }
[ "private", "function", "createSmf", "(", ")", "{", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Persister\\MongoDb\\StorageMetadataFactory'", ")", ",", "[", "new", "Reference", "(", "Utility", "::", "getAliasedName", "(", "'util.entity'", ")", ")", "]", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "return", "$", "definition", ";", "}" ]
Creates the storage metadata factory service definition. @return Definition
[ "Creates", "the", "storage", "metadata", "factory", "service", "definition", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Persisters.php#L210-L218
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.indexAction
public function indexAction() { $em = $this->getDoctrineManager(); $sakonninTemplates = $em->getRepository('BisonLabSakonninBundle:SakonninTemplate')->findAll(); return $this->render('BisonLabSakonninBundle:SakonninTemplate:index.html.twig', array( 'sakonninTemplates' => $sakonninTemplates,)); }
php
public function indexAction() { $em = $this->getDoctrineManager(); $sakonninTemplates = $em->getRepository('BisonLabSakonninBundle:SakonninTemplate')->findAll(); return $this->render('BisonLabSakonninBundle:SakonninTemplate:index.html.twig', array( 'sakonninTemplates' => $sakonninTemplates,)); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "sakonninTemplates", "=", "$", "em", "->", "getRepository", "(", "'BisonLabSakonninBundle:SakonninTemplate'", ")", "->", "findAll", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:SakonninTemplate:index.html.twig'", ",", "array", "(", "'sakonninTemplates'", "=>", "$", "sakonninTemplates", ",", ")", ")", ";", "}" ]
Lists all sakonninTemplate entities. @Route("/", name="sakonnintemplate_index", methods={"GET"})
[ "Lists", "all", "sakonninTemplate", "entities", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L24-L32
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.newAction
public function newAction(Request $request) { $sakonninTemplate = new Sakonnintemplate(); $default_lang_code = $this->container->get('translator')->getLocale(); $sakonninTemplate->setLangCode($default_lang_code); $form = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->persist($sakonninTemplate); $em->flush(); return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId())); } return $this->render('BisonLabSakonninBundle:SakonninTemplate:new.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'form' => $form->createView(), )); }
php
public function newAction(Request $request) { $sakonninTemplate = new Sakonnintemplate(); $default_lang_code = $this->container->get('translator')->getLocale(); $sakonninTemplate->setLangCode($default_lang_code); $form = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->persist($sakonninTemplate); $em->flush(); return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId())); } return $this->render('BisonLabSakonninBundle:SakonninTemplate:new.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", "Request", "$", "request", ")", "{", "$", "sakonninTemplate", "=", "new", "Sakonnintemplate", "(", ")", ";", "$", "default_lang_code", "=", "$", "this", "->", "container", "->", "get", "(", "'translator'", ")", "->", "getLocale", "(", ")", ";", "$", "sakonninTemplate", "->", "setLangCode", "(", "$", "default_lang_code", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'BisonLab\\SakonninBundle\\Form\\SakonninTemplateType'", ",", "$", "sakonninTemplate", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "sakonninTemplate", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'sakonnintemplate_show'", ",", "array", "(", "'id'", "=>", "$", "sakonninTemplate", "->", "getId", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:SakonninTemplate:new.html.twig'", ",", "array", "(", "'sakonninTemplate'", "=>", "$", "sakonninTemplate", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Creates a new sakonninTemplate entity. @Route("/new", name="sakonnintemplate_new", methods={"GET", "POST"})
[ "Creates", "a", "new", "sakonninTemplate", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L39-L60
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.showAction
public function showAction(SakonninTemplate $sakonninTemplate) { $deleteForm = $this->createDeleteForm($sakonninTemplate); return $this->render('BisonLabSakonninBundle:SakonninTemplate:show.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'delete_form' => $deleteForm->createView(), )); }
php
public function showAction(SakonninTemplate $sakonninTemplate) { $deleteForm = $this->createDeleteForm($sakonninTemplate); return $this->render('BisonLabSakonninBundle:SakonninTemplate:show.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'delete_form' => $deleteForm->createView(), )); }
[ "public", "function", "showAction", "(", "SakonninTemplate", "$", "sakonninTemplate", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "sakonninTemplate", ")", ";", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:SakonninTemplate:show.html.twig'", ",", "array", "(", "'sakonninTemplate'", "=>", "$", "sakonninTemplate", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Finds and displays a sakonninTemplate entity. @Route("/{id}", name="sakonnintemplate_show", methods={"GET"})
[ "Finds", "and", "displays", "a", "sakonninTemplate", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L67-L76
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.editAction
public function editAction(Request $request, SakonninTemplate $sakonninTemplate) { $deleteForm = $this->createDeleteForm($sakonninTemplate); $editForm = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrineManager()->flush(); return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId())); } return $this->render('BisonLabSakonninBundle:SakonninTemplate:edit.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); }
php
public function editAction(Request $request, SakonninTemplate $sakonninTemplate) { $deleteForm = $this->createDeleteForm($sakonninTemplate); $editForm = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrineManager()->flush(); return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId())); } return $this->render('BisonLabSakonninBundle:SakonninTemplate:edit.html.twig', array( 'sakonninTemplate' => $sakonninTemplate, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "SakonninTemplate", "$", "sakonninTemplate", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "sakonninTemplate", ")", ";", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "'BisonLab\\SakonninBundle\\Form\\SakonninTemplateType'", ",", "$", "sakonninTemplate", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isSubmitted", "(", ")", "&&", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'sakonnintemplate_show'", ",", "array", "(", "'id'", "=>", "$", "sakonninTemplate", "->", "getId", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:SakonninTemplate:edit.html.twig'", ",", "array", "(", "'sakonninTemplate'", "=>", "$", "sakonninTemplate", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to edit an existing sakonninTemplate entity. @Route("/{id}/edit", name="sakonnintemplate_edit", methods={"GET", "POST"})
[ "Displays", "a", "form", "to", "edit", "an", "existing", "sakonninTemplate", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L83-L101
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.deleteAction
public function deleteAction(Request $request, SakonninTemplate $sakonninTemplate) { $form = $this->createDeleteForm($sakonninTemplate); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->remove($sakonninTemplate); $em->flush(); } return $this->redirectToRoute('sakonnintemplate_index'); }
php
public function deleteAction(Request $request, SakonninTemplate $sakonninTemplate) { $form = $this->createDeleteForm($sakonninTemplate); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->remove($sakonninTemplate); $em->flush(); } return $this->redirectToRoute('sakonnintemplate_index'); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "SakonninTemplate", "$", "sakonninTemplate", ")", "{", "$", "form", "=", "$", "this", "->", "createDeleteForm", "(", "$", "sakonninTemplate", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "sakonninTemplate", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}", "return", "$", "this", "->", "redirectToRoute", "(", "'sakonnintemplate_index'", ")", ";", "}" ]
Deletes a sakonninTemplate entity. @Route("/{id}", name="sakonnintemplate_delete", methods={"DELETE"})
[ "Deletes", "a", "sakonninTemplate", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L108-L120
train
thomasez/BisonLabSakonninBundle
Controller/SakonninTemplateController.php
SakonninTemplateController.createDeleteForm
private function createDeleteForm(SakonninTemplate $sakonninTemplate) { return $this->createFormBuilder() ->setAction($this->generateUrl('sakonnintemplate_delete', array('id' => $sakonninTemplate->getId()))) ->setMethod('DELETE') ->getForm() ; }
php
private function createDeleteForm(SakonninTemplate $sakonninTemplate) { return $this->createFormBuilder() ->setAction($this->generateUrl('sakonnintemplate_delete', array('id' => $sakonninTemplate->getId()))) ->setMethod('DELETE') ->getForm() ; }
[ "private", "function", "createDeleteForm", "(", "SakonninTemplate", "$", "sakonninTemplate", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'sakonnintemplate_delete'", ",", "array", "(", "'id'", "=>", "$", "sakonninTemplate", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'DELETE'", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a sakonninTemplate entity. @param SakonninTemplate $sakonninTemplate The sakonninTemplate entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "delete", "a", "sakonninTemplate", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/SakonninTemplateController.php#L129-L136
train
Wedeto/DB
src/Query/JoinClause.php
JoinClause.toSQL
public function toSQL(Parameters $params, bool $inner_clause) { $drv = $params->getDriver(); $table = $drv->toSQL($params, $this->getTable()); $condition = $drv->toSQL($params, $this->getCondition()); return $this->getType() . " JOIN " . $table . " ON " . $condition; }
php
public function toSQL(Parameters $params, bool $inner_clause) { $drv = $params->getDriver(); $table = $drv->toSQL($params, $this->getTable()); $condition = $drv->toSQL($params, $this->getCondition()); return $this->getType() . " JOIN " . $table . " ON " . $condition; }
[ "public", "function", "toSQL", "(", "Parameters", "$", "params", ",", "bool", "$", "inner_clause", ")", "{", "$", "drv", "=", "$", "params", "->", "getDriver", "(", ")", ";", "$", "table", "=", "$", "drv", "->", "toSQL", "(", "$", "params", ",", "$", "this", "->", "getTable", "(", ")", ")", ";", "$", "condition", "=", "$", "drv", "->", "toSQL", "(", "$", "params", ",", "$", "this", "->", "getCondition", "(", ")", ")", ";", "return", "$", "this", "->", "getType", "(", ")", ".", "\" JOIN \"", ".", "$", "table", ".", "\" ON \"", ".", "$", "condition", ";", "}" ]
Write a JOIN clause to SQL query syntax @param Parameters $params The query parameters: tables and placeholder values @param bool $inner_clause @return string The generated SQL
[ "Write", "a", "JOIN", "clause", "to", "SQL", "query", "syntax" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/JoinClause.php#L92-L98
train
dann95/ts3-php
TeamSpeak3/Adapter/FileTransfer.php
FileTransfer.download
public function download($ftkey, $size, $passthru = false) { $this->init($ftkey); if ($passthru) { return $this->passthru($size); } $buff = new String(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for ($seek = 0; $seek < $size;) { $rest = $size - $seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek + $pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if (strlen($buff) != $size) { throw new Ts3Exception( "incomplete file download (" . count($buff) . " of " . $size . " bytes)" ); } return $buff; }
php
public function download($ftkey, $size, $passthru = false) { $this->init($ftkey); if ($passthru) { return $this->passthru($size); } $buff = new String(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for ($seek = 0; $seek < $size;) { $rest = $size - $seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek + $pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if (strlen($buff) != $size) { throw new Ts3Exception( "incomplete file download (" . count($buff) . " of " . $size . " bytes)" ); } return $buff; }
[ "public", "function", "download", "(", "$", "ftkey", ",", "$", "size", ",", "$", "passthru", "=", "false", ")", "{", "$", "this", "->", "init", "(", "$", "ftkey", ")", ";", "if", "(", "$", "passthru", ")", "{", "return", "$", "this", "->", "passthru", "(", "$", "size", ")", ";", "}", "$", "buff", "=", "new", "String", "(", "\"\"", ")", ";", "$", "size", "=", "intval", "(", "$", "size", ")", ";", "$", "pack", "=", "4096", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadStarted\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "for", "(", "$", "seek", "=", "0", ";", "$", "seek", "<", "$", "size", ";", ")", "{", "$", "rest", "=", "$", "size", "-", "$", "seek", ";", "$", "pack", "=", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ";", "$", "data", "=", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ")", ";", "$", "seek", "=", "$", "seek", "+", "$", "pack", ";", "$", "buff", "->", "append", "(", "$", "data", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadProgress\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "}", "$", "this", "->", "getProfiler", "(", ")", "->", "stop", "(", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadFinished\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "if", "(", "strlen", "(", "$", "buff", ")", "!=", "$", "size", ")", "{", "throw", "new", "Ts3Exception", "(", "\"incomplete file download (\"", ".", "count", "(", "$", "buff", ")", ".", "\" of \"", ".", "$", "size", ".", "\" bytes)\"", ")", ";", "}", "return", "$", "buff", ";", "}" ]
Returns the content of a downloaded file as a String object. @param string $ftkey @param integer $size @param boolean $passthru @throws Ts3Exception @return String
[ "Returns", "the", "content", "of", "a", "downloaded", "file", "as", "a", "String", "object", "." ]
d4693d78b54be0177a2b5fab316c0ff9d036238d
https://github.com/dann95/ts3-php/blob/d4693d78b54be0177a2b5fab316c0ff9d036238d/TeamSpeak3/Adapter/FileTransfer.php#L141-L177
train
ekyna/Table
Util/ColumnSort.php
ColumnSort.isValid
static public function isValid($direction, $throw = false) { $valid = in_array($direction, [ static::NONE, static::ASC, static::DESC, ], true); if (!$valid && $throw) { throw new InvalidArgumentException(sprintf("The direction '%s' is not valid.", $direction)); } return $valid; }
php
static public function isValid($direction, $throw = false) { $valid = in_array($direction, [ static::NONE, static::ASC, static::DESC, ], true); if (!$valid && $throw) { throw new InvalidArgumentException(sprintf("The direction '%s' is not valid.", $direction)); } return $valid; }
[ "static", "public", "function", "isValid", "(", "$", "direction", ",", "$", "throw", "=", "false", ")", "{", "$", "valid", "=", "in_array", "(", "$", "direction", ",", "[", "static", "::", "NONE", ",", "static", "::", "ASC", ",", "static", "::", "DESC", ",", "]", ",", "true", ")", ";", "if", "(", "!", "$", "valid", "&&", "$", "throw", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"The direction '%s' is not valid.\"", ",", "$", "direction", ")", ")", ";", "}", "return", "$", "valid", ";", "}" ]
Returns whether the given direction is valid. @param string $direction @param bool $throw @return bool
[ "Returns", "whether", "the", "given", "direction", "is", "valid", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Util/ColumnSort.php#L27-L40
train
t-kanstantsin/fileupload
src/model/Container.php
Container.configure
public static function configure($object, $properties) { foreach ($properties as $name => $value) { if (!property_exists($object, $name)) { throw new InvalidConfigException(sprintf('Property %s in class %s not found.', $name, \get_class($object))); } $object->$name = $value; } return $object; }
php
public static function configure($object, $properties) { foreach ($properties as $name => $value) { if (!property_exists($object, $name)) { throw new InvalidConfigException(sprintf('Property %s in class %s not found.', $name, \get_class($object))); } $object->$name = $value; } return $object; }
[ "public", "static", "function", "configure", "(", "$", "object", ",", "$", "properties", ")", "{", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "name", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "sprintf", "(", "'Property %s in class %s not found.'", ",", "$", "name", ",", "\\", "get_class", "(", "$", "object", ")", ")", ")", ";", "}", "$", "object", "->", "$", "name", "=", "$", "value", ";", "}", "return", "$", "object", ";", "}" ]
Configures an object with the initial property values. Inspired by Yii2. @see \yii\BaseYii::configure @param object $object the object to be configured @param array $properties the property initial values given in terms of name-value pairs. @return object the object itself @throws InvalidConfigException
[ "Configures", "an", "object", "with", "the", "initial", "property", "values", ".", "Inspired", "by", "Yii2", "." ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/model/Container.php#L22-L32
train
t-kanstantsin/fileupload
src/model/Container.php
Container.createObject
public static function createObject($type) { if (\is_string($type)) { return static::get($type); } elseif (\is_array($type)) { if (!isset($type['class'])) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); } $class = $type['class']; unset($type['class']); return static::get($class, $type); } throw new InvalidConfigException('Unsupported configuration type: ' . \gettype($type)); }
php
public static function createObject($type) { if (\is_string($type)) { return static::get($type); } elseif (\is_array($type)) { if (!isset($type['class'])) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); } $class = $type['class']; unset($type['class']); return static::get($class, $type); } throw new InvalidConfigException('Unsupported configuration type: ' . \gettype($type)); }
[ "public", "static", "function", "createObject", "(", "$", "type", ")", "{", "if", "(", "\\", "is_string", "(", "$", "type", ")", ")", "{", "return", "static", "::", "get", "(", "$", "type", ")", ";", "}", "elseif", "(", "\\", "is_array", "(", "$", "type", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "type", "[", "'class'", "]", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "'Object configuration must be an array containing a \"class\" element.'", ")", ";", "}", "$", "class", "=", "$", "type", "[", "'class'", "]", ";", "unset", "(", "$", "type", "[", "'class'", "]", ")", ";", "return", "static", "::", "get", "(", "$", "class", ",", "$", "type", ")", ";", "}", "throw", "new", "InvalidConfigException", "(", "'Unsupported configuration type: '", ".", "\\", "gettype", "(", "$", "type", ")", ")", ";", "}" ]
Creates a new object using the given configuration. Inspired by Yii2. @see \yii\BaseYii::createObject @param string|array $type @return mixed @throws InvalidConfigException @throws \ReflectionException
[ "Creates", "a", "new", "object", "using", "the", "given", "configuration", ".", "Inspired", "by", "Yii2", "." ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/model/Container.php#L42-L58
train
t-kanstantsin/fileupload
src/model/Container.php
Container.get
public static function get(string $class, array $config = []) { $reflection = new \ReflectionClass($class); if (!$reflection->isInstantiable()) { throw new \ReflectionException(sprintf('`%s` is not instantiable.', $reflection->name)); } if ($reflection->implementsInterface(IConfigurable::class)) { // set $config as the last parameter (existing one will be overwritten) return $reflection->newInstanceArgs([$config]); } $object = $reflection->newInstance(); static::configure($object, $config); return $object; }
php
public static function get(string $class, array $config = []) { $reflection = new \ReflectionClass($class); if (!$reflection->isInstantiable()) { throw new \ReflectionException(sprintf('`%s` is not instantiable.', $reflection->name)); } if ($reflection->implementsInterface(IConfigurable::class)) { // set $config as the last parameter (existing one will be overwritten) return $reflection->newInstanceArgs([$config]); } $object = $reflection->newInstance(); static::configure($object, $config); return $object; }
[ "public", "static", "function", "get", "(", "string", "$", "class", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "!", "$", "reflection", "->", "isInstantiable", "(", ")", ")", "{", "throw", "new", "\\", "ReflectionException", "(", "sprintf", "(", "'`%s` is not instantiable.'", ",", "$", "reflection", "->", "name", ")", ")", ";", "}", "if", "(", "$", "reflection", "->", "implementsInterface", "(", "IConfigurable", "::", "class", ")", ")", "{", "// set $config as the last parameter (existing one will be overwritten)", "return", "$", "reflection", "->", "newInstanceArgs", "(", "[", "$", "config", "]", ")", ";", "}", "$", "object", "=", "$", "reflection", "->", "newInstance", "(", ")", ";", "static", "::", "configure", "(", "$", "object", ",", "$", "config", ")", ";", "return", "$", "object", ";", "}" ]
Creates an instance of the specified class. Inspired by Yii2 di. @see \yii\di\Container::build @param string $class the class name @param array $config configurations to be applied to the new instance @return mixed @throws \ReflectionException @throws InvalidConfigException
[ "Creates", "an", "instance", "of", "the", "specified", "class", ".", "Inspired", "by", "Yii2", "di", "." ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/model/Container.php#L69-L85
train
eureka-framework/component-password
src/Password/Password.php
Password.generate
public function generate($length = 16, $alpha = 0.6, $numeric = 0.2, $other = 0.2) { $chars = array(); //~ Alphabetic characters for ($index = 0, $max = ceil($alpha * $length); $index < $max; $index++) { if ((bool) rand(0, 1)) { $char = rand(65, 90); // Upper } else { $char = rand(97, 122); // Lower } $chars[] = chr($char); } //~ Alphabetic characters for ($index = 0, $max = ceil($numeric * $length); $index < $max; $index++) { $char = rand(48, 57); // Number $chars[] = chr($char); } //~ Other printable chars for ($index = 0, $max = ceil($other * $length); $index < $max; $index++) { switch ((int) rand(1, 4)) { case 1: $char = rand(33, 47); break; case 2: $char = rand(58, 64); break; case 3: $char = rand(91, 96); break; case 4: default: $char = rand(123, 126); break; } $chars[] = chr($char); } shuffle($chars); $this->password = implode('', array_slice($chars, 0, 16)); return $this; }
php
public function generate($length = 16, $alpha = 0.6, $numeric = 0.2, $other = 0.2) { $chars = array(); //~ Alphabetic characters for ($index = 0, $max = ceil($alpha * $length); $index < $max; $index++) { if ((bool) rand(0, 1)) { $char = rand(65, 90); // Upper } else { $char = rand(97, 122); // Lower } $chars[] = chr($char); } //~ Alphabetic characters for ($index = 0, $max = ceil($numeric * $length); $index < $max; $index++) { $char = rand(48, 57); // Number $chars[] = chr($char); } //~ Other printable chars for ($index = 0, $max = ceil($other * $length); $index < $max; $index++) { switch ((int) rand(1, 4)) { case 1: $char = rand(33, 47); break; case 2: $char = rand(58, 64); break; case 3: $char = rand(91, 96); break; case 4: default: $char = rand(123, 126); break; } $chars[] = chr($char); } shuffle($chars); $this->password = implode('', array_slice($chars, 0, 16)); return $this; }
[ "public", "function", "generate", "(", "$", "length", "=", "16", ",", "$", "alpha", "=", "0.6", ",", "$", "numeric", "=", "0.2", ",", "$", "other", "=", "0.2", ")", "{", "$", "chars", "=", "array", "(", ")", ";", "//~ Alphabetic characters", "for", "(", "$", "index", "=", "0", ",", "$", "max", "=", "ceil", "(", "$", "alpha", "*", "$", "length", ")", ";", "$", "index", "<", "$", "max", ";", "$", "index", "++", ")", "{", "if", "(", "(", "bool", ")", "rand", "(", "0", ",", "1", ")", ")", "{", "$", "char", "=", "rand", "(", "65", ",", "90", ")", ";", "// Upper", "}", "else", "{", "$", "char", "=", "rand", "(", "97", ",", "122", ")", ";", "// Lower", "}", "$", "chars", "[", "]", "=", "chr", "(", "$", "char", ")", ";", "}", "//~ Alphabetic characters", "for", "(", "$", "index", "=", "0", ",", "$", "max", "=", "ceil", "(", "$", "numeric", "*", "$", "length", ")", ";", "$", "index", "<", "$", "max", ";", "$", "index", "++", ")", "{", "$", "char", "=", "rand", "(", "48", ",", "57", ")", ";", "// Number", "$", "chars", "[", "]", "=", "chr", "(", "$", "char", ")", ";", "}", "//~ Other printable chars", "for", "(", "$", "index", "=", "0", ",", "$", "max", "=", "ceil", "(", "$", "other", "*", "$", "length", ")", ";", "$", "index", "<", "$", "max", ";", "$", "index", "++", ")", "{", "switch", "(", "(", "int", ")", "rand", "(", "1", ",", "4", ")", ")", "{", "case", "1", ":", "$", "char", "=", "rand", "(", "33", ",", "47", ")", ";", "break", ";", "case", "2", ":", "$", "char", "=", "rand", "(", "58", ",", "64", ")", ";", "break", ";", "case", "3", ":", "$", "char", "=", "rand", "(", "91", ",", "96", ")", ";", "break", ";", "case", "4", ":", "default", ":", "$", "char", "=", "rand", "(", "123", ",", "126", ")", ";", "break", ";", "}", "$", "chars", "[", "]", "=", "chr", "(", "$", "char", ")", ";", "}", "shuffle", "(", "$", "chars", ")", ";", "$", "this", "->", "password", "=", "implode", "(", "''", ",", "array_slice", "(", "$", "chars", ",", "0", ",", "16", ")", ")", ";", "return", "$", "this", ";", "}" ]
Generate password of given length. @param int $length @param float $alpha % alphabetic chars. @param float $numeric % of numeric chars @param float $other % of other chars @return self
[ "Generate", "password", "of", "given", "length", "." ]
1eed8c97531e64a7bd6f7f58625a684b1dce34c5
https://github.com/eureka-framework/component-password/blob/1eed8c97531e64a7bd6f7f58625a684b1dce34c5/src/Password/Password.php#L48-L96
train
itkg/core
src/Itkg/Core/Command/DatabaseListCommand.php
DatabaseListCommand.configureOptions
protected function configureOptions(InputInterface $input) { if ($input->getOption('path')) { $this->finder->setPath($input->getOption('path')); $this->locator->setParams(array('path' => $input->getOption('path'))); } }
php
protected function configureOptions(InputInterface $input) { if ($input->getOption('path')) { $this->finder->setPath($input->getOption('path')); $this->locator->setParams(array('path' => $input->getOption('path'))); } }
[ "protected", "function", "configureOptions", "(", "InputInterface", "$", "input", ")", "{", "if", "(", "$", "input", "->", "getOption", "(", "'path'", ")", ")", "{", "$", "this", "->", "finder", "->", "setPath", "(", "$", "input", "->", "getOption", "(", "'path'", ")", ")", ";", "$", "this", "->", "locator", "->", "setParams", "(", "array", "(", "'path'", "=>", "$", "input", "->", "getOption", "(", "'path'", ")", ")", ")", ";", "}", "}" ]
Configure input options @param InputInterface $input
[ "Configure", "input", "options" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseListCommand.php#L119-L125
train
itkg/core
src/Itkg/Core/Command/DatabaseListCommand.php
DatabaseListCommand.display
protected function display(OutputInterface $output, array $rows = array(), array $failed = array()) { $this->getApplication()->getHelperSet()->get('table') ->setHeaders(array('Name', 'Scripts', 'Rollbacks', 'Status')) ->setRows($rows) ->render($output); if (!empty($failed)) { $output->writeln(sprintf('<fg=red>Check failed for release(s) %s</fg=red>', implode(', ', $failed))); } }
php
protected function display(OutputInterface $output, array $rows = array(), array $failed = array()) { $this->getApplication()->getHelperSet()->get('table') ->setHeaders(array('Name', 'Scripts', 'Rollbacks', 'Status')) ->setRows($rows) ->render($output); if (!empty($failed)) { $output->writeln(sprintf('<fg=red>Check failed for release(s) %s</fg=red>', implode(', ', $failed))); } }
[ "protected", "function", "display", "(", "OutputInterface", "$", "output", ",", "array", "$", "rows", "=", "array", "(", ")", ",", "array", "$", "failed", "=", "array", "(", ")", ")", "{", "$", "this", "->", "getApplication", "(", ")", "->", "getHelperSet", "(", ")", "->", "get", "(", "'table'", ")", "->", "setHeaders", "(", "array", "(", "'Name'", ",", "'Scripts'", ",", "'Rollbacks'", ",", "'Status'", ")", ")", "->", "setRows", "(", "$", "rows", ")", "->", "render", "(", "$", "output", ")", ";", "if", "(", "!", "empty", "(", "$", "failed", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<fg=red>Check failed for release(s) %s</fg=red>'", ",", "implode", "(", "', '", ",", "$", "failed", ")", ")", ")", ";", "}", "}" ]
Display result as a table @param OutputInterface $output @param array $rows
[ "Display", "result", "as", "a", "table" ]
e5e4efb05feb4d23b0df41f2b21fd095103e593b
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseListCommand.php#L133-L143
train
hiqdev/minii-helpers
src/BaseUrl.php
BaseUrl.toRoute
public static function toRoute($route, $scheme = false) { $route = (array) $route; $route[0] = static::normalizeRoute($route[0]); if ($scheme) { return Yii::$app->getUrlManager()->createAbsoluteUrl($route, is_string($scheme) ? $scheme : null); } else { return Yii::$app->getUrlManager()->createUrl($route); } }
php
public static function toRoute($route, $scheme = false) { $route = (array) $route; $route[0] = static::normalizeRoute($route[0]); if ($scheme) { return Yii::$app->getUrlManager()->createAbsoluteUrl($route, is_string($scheme) ? $scheme : null); } else { return Yii::$app->getUrlManager()->createUrl($route); } }
[ "public", "static", "function", "toRoute", "(", "$", "route", ",", "$", "scheme", "=", "false", ")", "{", "$", "route", "=", "(", "array", ")", "$", "route", ";", "$", "route", "[", "0", "]", "=", "static", "::", "normalizeRoute", "(", "$", "route", "[", "0", "]", ")", ";", "if", "(", "$", "scheme", ")", "{", "return", "Yii", "::", "$", "app", "->", "getUrlManager", "(", ")", "->", "createAbsoluteUrl", "(", "$", "route", ",", "is_string", "(", "$", "scheme", ")", "?", "$", "scheme", ":", "null", ")", ";", "}", "else", "{", "return", "Yii", "::", "$", "app", "->", "getUrlManager", "(", ")", "->", "createUrl", "(", "$", "route", ")", ";", "}", "}" ]
Creates a URL for the given route. This method will use [[\yii\web\UrlManager]] to create a URL. You may specify the route as a string, e.g., `site/index`. You may also use an array if you want to specify additional query parameters for the URL being created. The array format must be: ```php // generates: /index.php?r=site/index&param1=value1&param2=value2 ['site/index', 'param1' => 'value1', 'param2' => 'value2'] ``` If you want to create a URL with an anchor, you can use the array format with a `#` parameter. For example, ```php // generates: /index.php?r=site/index&param1=value1#name ['site/index', 'param1' => 'value1', '#' => 'name'] ``` A route may be either absolute or relative. An absolute route has a leading slash (e.g. `/site/index`), while a relative route has none (e.g. `site/index` or `index`). A relative route will be converted into an absolute one by the following rules: - If the route is an empty string, the current [[\yii\web\Controller::route|route]] will be used; - If the route contains no slashes at all (e.g. `index`), it is considered to be an action ID of the current controller and will be prepended with [[\yii\web\Controller::uniqueId]]; - If the route has no leading slash (e.g. `site/index`), it is considered to be a route relative to the current module and will be prepended with the module's [[\yii\base\Module::uniqueId|uniqueId]]. Starting from version 2.0.2, a route can also be specified as an alias. In this case, the alias will be converted into the actual route first before conducting the above transformation steps. Below are some examples of using this method: ```php // /index.php?r=site/index echo Url::toRoute('site/index'); // /index.php?r=site/index&src=ref1#name echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']); // http://www.example.com/index.php?r=site/index echo Url::toRoute('site/index', true); // https://www.example.com/index.php?r=site/index echo Url::toRoute('site/index', 'https'); // /index.php?r=post/index assume the alias "@posts" is defined as "post/index" echo Url::toRoute('@posts'); ``` @param string|array $route use a string to represent a route (e.g. `index`, `site/index`), or an array to represent a route with query parameters (e.g. `['site/index', 'param1' => 'value1']`). @param boolean|string $scheme the URI scheme to use in the generated URL: - `false` (default): generating a relative URL. - `true`: returning an absolute base URL whose scheme is the same as that in [[\yii\web\UrlManager::hostInfo]]. - string: generating an absolute URL with the specified scheme (either `http` or `https`). @return string the generated URL @throws InvalidParamException a relative route is given while there is no active controller
[ "Creates", "a", "URL", "for", "the", "given", "route", "." ]
001b7a56a6ebdc432c4683fe47c00a913f8e57d7
https://github.com/hiqdev/minii-helpers/blob/001b7a56a6ebdc432c4683fe47c00a913f8e57d7/src/BaseUrl.php#L88-L98
train
hiqdev/minii-helpers
src/BaseUrl.php
BaseUrl.to
public static function to($url = '', $scheme = false) { if (is_array($url)) { return static::toRoute($url, $scheme); } $url = Yii::getAlias($url); if ($url === '') { $url = Yii::$app->getRequest()->getUrl(); } if (!$scheme) { return $url; } if (strncmp($url, '//', 2) === 0) { // e.g. //hostname/path/to/resource return is_string($scheme) ? "$scheme:$url" : $url; } if (($pos = strpos($url, ':')) == false || !ctype_alpha(substr($url, 0, $pos))) { // turn relative URL into absolute $url = Yii::$app->getUrlManager()->getHostInfo() . '/' . ltrim($url, '/'); } if (is_string($scheme) && ($pos = strpos($url, ':')) !== false) { // replace the scheme with the specified one $url = $scheme . substr($url, $pos); } return $url; }
php
public static function to($url = '', $scheme = false) { if (is_array($url)) { return static::toRoute($url, $scheme); } $url = Yii::getAlias($url); if ($url === '') { $url = Yii::$app->getRequest()->getUrl(); } if (!$scheme) { return $url; } if (strncmp($url, '//', 2) === 0) { // e.g. //hostname/path/to/resource return is_string($scheme) ? "$scheme:$url" : $url; } if (($pos = strpos($url, ':')) == false || !ctype_alpha(substr($url, 0, $pos))) { // turn relative URL into absolute $url = Yii::$app->getUrlManager()->getHostInfo() . '/' . ltrim($url, '/'); } if (is_string($scheme) && ($pos = strpos($url, ':')) !== false) { // replace the scheme with the specified one $url = $scheme . substr($url, $pos); } return $url; }
[ "public", "static", "function", "to", "(", "$", "url", "=", "''", ",", "$", "scheme", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "url", ")", ")", "{", "return", "static", "::", "toRoute", "(", "$", "url", ",", "$", "scheme", ")", ";", "}", "$", "url", "=", "Yii", "::", "getAlias", "(", "$", "url", ")", ";", "if", "(", "$", "url", "===", "''", ")", "{", "$", "url", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "getUrl", "(", ")", ";", "}", "if", "(", "!", "$", "scheme", ")", "{", "return", "$", "url", ";", "}", "if", "(", "strncmp", "(", "$", "url", ",", "'//'", ",", "2", ")", "===", "0", ")", "{", "// e.g. //hostname/path/to/resource", "return", "is_string", "(", "$", "scheme", ")", "?", "\"$scheme:$url\"", ":", "$", "url", ";", "}", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "url", ",", "':'", ")", ")", "==", "false", "||", "!", "ctype_alpha", "(", "substr", "(", "$", "url", ",", "0", ",", "$", "pos", ")", ")", ")", "{", "// turn relative URL into absolute", "$", "url", "=", "Yii", "::", "$", "app", "->", "getUrlManager", "(", ")", "->", "getHostInfo", "(", ")", ".", "'/'", ".", "ltrim", "(", "$", "url", ",", "'/'", ")", ";", "}", "if", "(", "is_string", "(", "$", "scheme", ")", "&&", "(", "$", "pos", "=", "strpos", "(", "$", "url", ",", "':'", ")", ")", "!==", "false", ")", "{", "// replace the scheme with the specified one", "$", "url", "=", "$", "scheme", ".", "substr", "(", "$", "url", ",", "$", "pos", ")", ";", "}", "return", "$", "url", ";", "}" ]
Creates a URL based on the given parameters. This method is very similar to [[toRoute()]]. The only difference is that this method requires a route to be specified as an array only. If a string is given, it will be treated as a URL. In particular, if `$url` is - an array: [[toRoute()]] will be called to generate the URL. For example: `['site/index']`, `['post/index', 'page' => 2]`. Please refer to [[toRoute()]] for more details on how to specify a route. - a string with a leading `@`: it is treated as an alias, and the corresponding aliased string will be returned. - an empty string: the currently requested URL will be returned; - a normal string: it will be returned as is. When `$scheme` is specified (either a string or true), an absolute URL with host info (obtained from [[\yii\web\UrlManager::hostInfo]]) will be returned. If `$url` is already an absolute URL, its scheme will be replaced with the specified one. Below are some examples of using this method: ```php // /index.php?r=site/index echo Url::to(['site/index']); // /index.php?r=site/index&src=ref1#name echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']); // /index.php?r=post/index assume the alias "@posts" is defined as "/post/index" echo Url::to(['@posts']); // the currently requested URL echo Url::to(); // /images/logo.gif echo Url::to('@web/images/logo.gif'); // images/logo.gif echo Url::to('images/logo.gif'); // http://www.example.com/images/logo.gif echo Url::to('@web/images/logo.gif', true); // https://www.example.com/images/logo.gif echo Url::to('@web/images/logo.gif', 'https'); ``` @param array|string $url the parameter to be used to generate a valid URL @param boolean|string $scheme the URI scheme to use in the generated URL: - `false` (default): generating a relative URL. - `true`: returning an absolute base URL whose scheme is the same as that in [[\yii\web\UrlManager::hostInfo]]. - string: generating an absolute URL with the specified scheme (either `http` or `https`). @return string the generated URL @throws InvalidParamException a relative route is given while there is no active controller
[ "Creates", "a", "URL", "based", "on", "the", "given", "parameters", "." ]
001b7a56a6ebdc432c4683fe47c00a913f8e57d7
https://github.com/hiqdev/minii-helpers/blob/001b7a56a6ebdc432c4683fe47c00a913f8e57d7/src/BaseUrl.php#L199-L230
train
Hnto/nuki
src/Handlers/Repository/RepositoryHandler.php
RepositoryHandler.buildRepository
public function buildRepository(string $key) { $repositoryInfo = $this->get($key); if (is_null($repositoryInfo)) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s is not a registered repository', [$key])); } $this->validate($repositoryInfo, $key); $repository = new $repositoryInfo['Location']; return $repository; }
php
public function buildRepository(string $key) { $repositoryInfo = $this->get($key); if (is_null($repositoryInfo)) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s is not a registered repository', [$key])); } $this->validate($repositoryInfo, $key); $repository = new $repositoryInfo['Location']; return $repository; }
[ "public", "function", "buildRepository", "(", "string", "$", "key", ")", "{", "$", "repositoryInfo", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "if", "(", "is_null", "(", "$", "repositoryInfo", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "vsprintf", "(", "'%1$s is not a registered repository'", ",", "[", "$", "key", "]", ")", ")", ";", "}", "$", "this", "->", "validate", "(", "$", "repositoryInfo", ",", "$", "key", ")", ";", "$", "repository", "=", "new", "$", "repositoryInfo", "[", "'Location'", "]", ";", "return", "$", "repository", ";", "}" ]
Build a repository by its key and additional options @param string $key @return \Nuki\Skeletons\Providers\Repository @throws Base
[ "Build", "a", "repository", "by", "its", "key", "and", "additional", "options" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Repository/RepositoryHandler.php#L57-L69
train
Hnto/nuki
src/Handlers/Repository/RepositoryHandler.php
RepositoryHandler.validate
private function validate(array $repository = [], $key) { if (!isset($repository['Providers']) || empty($repository['Providers'])) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s does not have any providers', [$key])); } if (!class_exists($repository['Location'])) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s cannot be found', [$repository['Location']])); } }
php
private function validate(array $repository = [], $key) { if (!isset($repository['Providers']) || empty($repository['Providers'])) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s does not have any providers', [$key])); } if (!class_exists($repository['Location'])) { throw new \Nuki\Exceptions\Base(vsprintf('%1$s cannot be found', [$repository['Location']])); } }
[ "private", "function", "validate", "(", "array", "$", "repository", "=", "[", "]", ",", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "repository", "[", "'Providers'", "]", ")", "||", "empty", "(", "$", "repository", "[", "'Providers'", "]", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "vsprintf", "(", "'%1$s does not have any providers'", ",", "[", "$", "key", "]", ")", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "repository", "[", "'Location'", "]", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "vsprintf", "(", "'%1$s cannot be found'", ",", "[", "$", "repository", "[", "'Location'", "]", "]", ")", ")", ";", "}", "}" ]
Validate repository info @param array $repository @throws \Nuki\Exceptions\Base
[ "Validate", "repository", "info" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Repository/RepositoryHandler.php#L77-L85
train
eureka-framework/component-database
src/Database/Database.php
Database.getConnection
public function getConnection($name = null) { if ($name === null) { reset($this->config); $name = key($this->config); } if (!isset($this->config[$name])) { throw new \Exception('Configuration name does not exists !'); } if (!isset($this->config[$name]['engine'])) { throw new \Exception('Engine not specified in configuration !'); } $engine = $this->config[$name]['engine']; if (!isset($this->connections[$engine][$name])) { $method = 'get' . $engine; if (!method_exists($this, $method)) { throw new \Exception('Engine does not exists ! (engine: ' . $engine . ')'); } $this->connections[$engine][$name] = $this->$method($name); } return $this->connections[$engine][$name]; }
php
public function getConnection($name = null) { if ($name === null) { reset($this->config); $name = key($this->config); } if (!isset($this->config[$name])) { throw new \Exception('Configuration name does not exists !'); } if (!isset($this->config[$name]['engine'])) { throw new \Exception('Engine not specified in configuration !'); } $engine = $this->config[$name]['engine']; if (!isset($this->connections[$engine][$name])) { $method = 'get' . $engine; if (!method_exists($this, $method)) { throw new \Exception('Engine does not exists ! (engine: ' . $engine . ')'); } $this->connections[$engine][$name] = $this->$method($name); } return $this->connections[$engine][$name]; }
[ "public", "function", "getConnection", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "reset", "(", "$", "this", "->", "config", ")", ";", "$", "name", "=", "key", "(", "$", "this", "->", "config", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Configuration name does not exists !'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", "[", "'engine'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Engine not specified in configuration !'", ")", ";", "}", "$", "engine", "=", "$", "this", "->", "config", "[", "$", "name", "]", "[", "'engine'", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "connections", "[", "$", "engine", "]", "[", "$", "name", "]", ")", ")", "{", "$", "method", "=", "'get'", ".", "$", "engine", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Engine does not exists ! (engine: '", ".", "$", "engine", ".", "')'", ")", ";", "}", "$", "this", "->", "connections", "[", "$", "engine", "]", "[", "$", "name", "]", "=", "$", "this", "->", "$", "method", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "connections", "[", "$", "engine", "]", "[", "$", "name", "]", ";", "}" ]
Create or get existing connection. @param string $name @return \PDO @throws \Exception
[ "Create", "or", "get", "existing", "connection", "." ]
a8a44d8ecff5f692be968205cf2c520643344b5d
https://github.com/eureka-framework/component-database/blob/a8a44d8ecff5f692be968205cf2c520643344b5d/src/Database/Database.php#L95-L122
train
eureka-framework/component-database
src/Database/Database.php
Database.getPDO
protected function getPDO($name) { if (!isset($this->config[$name]) || !is_array($this->config[$name])) { throw new \Exception('Config not found ! (config: ' . $name . ')'); } $config = $this->config[$name]; if (!isset($config['dsn'])) { throw new \Exception('"dsn" parameter is not defined !'); } if (!isset($config['user'])) { throw new \Exception('"user" parameter is not defined !'); } if (!isset($config['pass'])) { throw new \Exception('"pass" parameter is not defined !'); } $config['options'] = isset($config['options']) ? $config['options'] : array(); $options = array(); foreach ($config['options'] as $name => $value) { if (0 === strpos($name, 'PDO::')) { $options[constant($name)] = $value; } } $connection = new \PDO($config['dsn'], $config['user'], $config['pass'], $options); $connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $connection; }
php
protected function getPDO($name) { if (!isset($this->config[$name]) || !is_array($this->config[$name])) { throw new \Exception('Config not found ! (config: ' . $name . ')'); } $config = $this->config[$name]; if (!isset($config['dsn'])) { throw new \Exception('"dsn" parameter is not defined !'); } if (!isset($config['user'])) { throw new \Exception('"user" parameter is not defined !'); } if (!isset($config['pass'])) { throw new \Exception('"pass" parameter is not defined !'); } $config['options'] = isset($config['options']) ? $config['options'] : array(); $options = array(); foreach ($config['options'] as $name => $value) { if (0 === strpos($name, 'PDO::')) { $options[constant($name)] = $value; } } $connection = new \PDO($config['dsn'], $config['user'], $config['pass'], $options); $connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $connection; }
[ "protected", "function", "getPDO", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Config not found ! (config: '", ".", "$", "name", ".", "')'", ")", ";", "}", "$", "config", "=", "$", "this", "->", "config", "[", "$", "name", "]", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'dsn'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'\"dsn\" parameter is not defined !'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'user'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'\"user\" parameter is not defined !'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'pass'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'\"pass\" parameter is not defined !'", ")", ";", "}", "$", "config", "[", "'options'", "]", "=", "isset", "(", "$", "config", "[", "'options'", "]", ")", "?", "$", "config", "[", "'options'", "]", ":", "array", "(", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "config", "[", "'options'", "]", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "name", ",", "'PDO::'", ")", ")", "{", "$", "options", "[", "constant", "(", "$", "name", ")", "]", "=", "$", "value", ";", "}", "}", "$", "connection", "=", "new", "\\", "PDO", "(", "$", "config", "[", "'dsn'", "]", ",", "$", "config", "[", "'user'", "]", ",", "$", "config", "[", "'pass'", "]", ",", "$", "options", ")", ";", "$", "connection", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ",", "\\", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "return", "$", "connection", ";", "}" ]
Create new PDO connection @param string $name Config name @return \PDO @throws \Exception
[ "Create", "new", "PDO", "connection" ]
a8a44d8ecff5f692be968205cf2c520643344b5d
https://github.com/eureka-framework/component-database/blob/a8a44d8ecff5f692be968205cf2c520643344b5d/src/Database/Database.php#L131-L164
train
MBHFramework/mbh-rest
Mbh/Container.php
Container.registerDefaultServices
private function registerDefaultServices($userSettings) { $defaultSettings = $this->defaultSettings; /** * This service MUST return an array or an * instance of ArrayAccess. * * @return array|ArrayAccess */ $this['settings'] = function () use ($userSettings, $defaultSettings) { return new Collection(array_merge($defaultSettings, $userSettings)); }; $defaultProvider = new DefaultServicesProvider(); $defaultProvider->register($this); }
php
private function registerDefaultServices($userSettings) { $defaultSettings = $this->defaultSettings; /** * This service MUST return an array or an * instance of ArrayAccess. * * @return array|ArrayAccess */ $this['settings'] = function () use ($userSettings, $defaultSettings) { return new Collection(array_merge($defaultSettings, $userSettings)); }; $defaultProvider = new DefaultServicesProvider(); $defaultProvider->register($this); }
[ "private", "function", "registerDefaultServices", "(", "$", "userSettings", ")", "{", "$", "defaultSettings", "=", "$", "this", "->", "defaultSettings", ";", "/**\n * This service MUST return an array or an\n * instance of ArrayAccess.\n *\n * @return array|ArrayAccess\n */", "$", "this", "[", "'settings'", "]", "=", "function", "(", ")", "use", "(", "$", "userSettings", ",", "$", "defaultSettings", ")", "{", "return", "new", "Collection", "(", "array_merge", "(", "$", "defaultSettings", ",", "$", "userSettings", ")", ")", ";", "}", ";", "$", "defaultProvider", "=", "new", "DefaultServicesProvider", "(", ")", ";", "$", "defaultProvider", "->", "register", "(", "$", "this", ")", ";", "}" ]
This function registers the default services that Mbh needs to work. All services are shared - that is, they are registered such that the same instance is returned on subsequent calls. @param array $userSettings Associative array of application settings @return void
[ "This", "function", "registers", "the", "default", "services", "that", "Mbh", "needs", "to", "work", "." ]
e23b4e66dc2b8da35e06312dcfdba41c4cfc2c83
https://github.com/MBHFramework/mbh-rest/blob/e23b4e66dc2b8da35e06312dcfdba41c4cfc2c83/Mbh/Container.php#L69-L85
train
imsamurai/CakePHP-AdvancedShell
Console/Command/Task/Scheduled/ScheduleSplitter.php
ScheduleSplitter.splitInner
public function splitInner(array $arguments = array()) { if (is_null($this->_InnerSplitter)) { return new ArrayIterator(array($arguments)); } return $this->_InnerSplitter->split($arguments); }
php
public function splitInner(array $arguments = array()) { if (is_null($this->_InnerSplitter)) { return new ArrayIterator(array($arguments)); } return $this->_InnerSplitter->split($arguments); }
[ "public", "function", "splitInner", "(", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_InnerSplitter", ")", ")", "{", "return", "new", "ArrayIterator", "(", "array", "(", "$", "arguments", ")", ")", ";", "}", "return", "$", "this", "->", "_InnerSplitter", "->", "split", "(", "$", "arguments", ")", ";", "}" ]
Returns iterator over arguments splitted by inner splitter @param array $arguments Script arguments @return Iterator
[ "Returns", "iterator", "over", "arguments", "splitted", "by", "inner", "splitter" ]
087d483742e2a76bee45e35b8d94957b0d20f857
https://github.com/imsamurai/CakePHP-AdvancedShell/blob/087d483742e2a76bee45e35b8d94957b0d20f857/Console/Command/Task/Scheduled/ScheduleSplitter.php#L49-L54
train
Subscribo/klarna-invoice-sdk-wrapped
src/pclasses/mysqlstorage.class.php
MySQLStorage.connect
public function connect() { $this->link = mysql_connect($this->addr, $this->user, $this->passwd); if ($this->link === false) { throw new Klarna_DatabaseException( 'Failed to connect to database! ('.mysql_error().')' ); } }
php
public function connect() { $this->link = mysql_connect($this->addr, $this->user, $this->passwd); if ($this->link === false) { throw new Klarna_DatabaseException( 'Failed to connect to database! ('.mysql_error().')' ); } }
[ "public", "function", "connect", "(", ")", "{", "$", "this", "->", "link", "=", "mysql_connect", "(", "$", "this", "->", "addr", ",", "$", "this", "->", "user", ",", "$", "this", "->", "passwd", ")", ";", "if", "(", "$", "this", "->", "link", "===", "false", ")", "{", "throw", "new", "Klarna_DatabaseException", "(", "'Failed to connect to database! ('", ".", "mysql_error", "(", ")", ".", "')'", ")", ";", "}", "}" ]
Establish a connection to the DB @throws Klarna_DatabaseException If a connection could not be made @return void
[ "Establish", "a", "connection", "to", "the", "DB" ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/pclasses/mysqlstorage.class.php#L118-L126
train
Subscribo/klarna-invoice-sdk-wrapped
src/pclasses/mysqlstorage.class.php
MySQLStorage.create
public function create() { if (!mysql_query( "CREATE DATABASE IF NOT EXISTS `{$this->dbName}`", $this->link ) ) { throw new Klarna_DatabaseException( 'Failed to create! ('.mysql_error().')' ); } $create = mysql_query( "CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` ( `eid` int(10) unsigned NOT NULL, `id` int(10) unsigned NOT NULL, `type` tinyint(4) NOT NULL, `description` varchar(255) NOT NULL, `months` int(11) NOT NULL, `interestrate` decimal(11,2) NOT NULL, `invoicefee` decimal(11,2) NOT NULL, `startfee` decimal(11,2) NOT NULL, `minamount` decimal(11,2) NOT NULL, `country` int(11) NOT NULL, `expire` int(11) NOT NULL, KEY `id` (`id`) )", $this->link ); if (!$create) { throw new Klarna_DatabaseException( 'Table not existing, failed to create! ('.mysql_error().')' ); } }
php
public function create() { if (!mysql_query( "CREATE DATABASE IF NOT EXISTS `{$this->dbName}`", $this->link ) ) { throw new Klarna_DatabaseException( 'Failed to create! ('.mysql_error().')' ); } $create = mysql_query( "CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` ( `eid` int(10) unsigned NOT NULL, `id` int(10) unsigned NOT NULL, `type` tinyint(4) NOT NULL, `description` varchar(255) NOT NULL, `months` int(11) NOT NULL, `interestrate` decimal(11,2) NOT NULL, `invoicefee` decimal(11,2) NOT NULL, `startfee` decimal(11,2) NOT NULL, `minamount` decimal(11,2) NOT NULL, `country` int(11) NOT NULL, `expire` int(11) NOT NULL, KEY `id` (`id`) )", $this->link ); if (!$create) { throw new Klarna_DatabaseException( 'Table not existing, failed to create! ('.mysql_error().')' ); } }
[ "public", "function", "create", "(", ")", "{", "if", "(", "!", "mysql_query", "(", "\"CREATE DATABASE IF NOT EXISTS `{$this->dbName}`\"", ",", "$", "this", "->", "link", ")", ")", "{", "throw", "new", "Klarna_DatabaseException", "(", "'Failed to create! ('", ".", "mysql_error", "(", ")", ".", "')'", ")", ";", "}", "$", "create", "=", "mysql_query", "(", "\"CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` (\n `eid` int(10) unsigned NOT NULL,\n `id` int(10) unsigned NOT NULL,\n `type` tinyint(4) NOT NULL,\n `description` varchar(255) NOT NULL,\n `months` int(11) NOT NULL,\n `interestrate` decimal(11,2) NOT NULL,\n `invoicefee` decimal(11,2) NOT NULL,\n `startfee` decimal(11,2) NOT NULL,\n `minamount` decimal(11,2) NOT NULL,\n `country` int(11) NOT NULL,\n `expire` int(11) NOT NULL,\n KEY `id` (`id`)\n )\"", ",", "$", "this", "->", "link", ")", ";", "if", "(", "!", "$", "create", ")", "{", "throw", "new", "Klarna_DatabaseException", "(", "'Table not existing, failed to create! ('", ".", "mysql_error", "(", ")", ".", "')'", ")", ";", "}", "}" ]
Initialize the DB by creating the necessary database tables. @throws Klarna_DatabaseException If tables could not be created @return void
[ "Initialize", "the", "DB", "by", "creating", "the", "necessary", "database", "tables", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/pclasses/mysqlstorage.class.php#L135-L169
train
Subscribo/klarna-invoice-sdk-wrapped
src/pclasses/mysqlstorage.class.php
MySQLStorage.save
public function save($uri) { $this->splitURI($uri); $this->connect(); if (!is_array($this->pclasses) || count($this->pclasses) == 0) { return; } foreach ($this->pclasses as $pclasses) { foreach ($pclasses as $pclass) { //Remove the pclass if it exists. mysql_query( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}` WHERE `id` = '{$pclass->getId()}' AND `eid` = '{$pclass->getEid()}'" ); //Insert it again. $result = mysql_query( "INSERT INTO `{$this->dbName}`.`{$this->dbTable}` (`eid`, `id`, `type`, `description`, `months`, `interestrate`, `invoicefee`, `startfee`, `minamount`, `country`, `expire` ) VALUES ('{$pclass->getEid()}', '{$pclass->getId()}', '{$pclass->getType()}', '{$pclass->getDescription()}', '{$pclass->getMonths()}', '{$pclass->getInterestRate()}', '{$pclass->getInvoiceFee()}', '{$pclass->getStartFee()}', '{$pclass->getMinAmount()}', '{$pclass->getCountry()}', '{$pclass->getExpire()}')", $this->link ); if ($result === false) { throw new Klarna_DatabaseException( 'INSERT INTO query failed! ('.mysql_error().')' ); } } } }
php
public function save($uri) { $this->splitURI($uri); $this->connect(); if (!is_array($this->pclasses) || count($this->pclasses) == 0) { return; } foreach ($this->pclasses as $pclasses) { foreach ($pclasses as $pclass) { //Remove the pclass if it exists. mysql_query( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}` WHERE `id` = '{$pclass->getId()}' AND `eid` = '{$pclass->getEid()}'" ); //Insert it again. $result = mysql_query( "INSERT INTO `{$this->dbName}`.`{$this->dbTable}` (`eid`, `id`, `type`, `description`, `months`, `interestrate`, `invoicefee`, `startfee`, `minamount`, `country`, `expire` ) VALUES ('{$pclass->getEid()}', '{$pclass->getId()}', '{$pclass->getType()}', '{$pclass->getDescription()}', '{$pclass->getMonths()}', '{$pclass->getInterestRate()}', '{$pclass->getInvoiceFee()}', '{$pclass->getStartFee()}', '{$pclass->getMinAmount()}', '{$pclass->getCountry()}', '{$pclass->getExpire()}')", $this->link ); if ($result === false) { throw new Klarna_DatabaseException( 'INSERT INTO query failed! ('.mysql_error().')' ); } } } }
[ "public", "function", "save", "(", "$", "uri", ")", "{", "$", "this", "->", "splitURI", "(", "$", "uri", ")", ";", "$", "this", "->", "connect", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "pclasses", ")", "||", "count", "(", "$", "this", "->", "pclasses", ")", "==", "0", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "pclasses", "as", "$", "pclasses", ")", "{", "foreach", "(", "$", "pclasses", "as", "$", "pclass", ")", "{", "//Remove the pclass if it exists.", "mysql_query", "(", "\"DELETE FROM `{$this->dbName}`.`{$this->dbTable}`\n WHERE `id` = '{$pclass->getId()}'\n AND `eid` = '{$pclass->getEid()}'\"", ")", ";", "//Insert it again.", "$", "result", "=", "mysql_query", "(", "\"INSERT INTO `{$this->dbName}`.`{$this->dbTable}`\n (`eid`,\n `id`,\n `type`,\n `description`,\n `months`,\n `interestrate`,\n `invoicefee`,\n `startfee`,\n `minamount`,\n `country`,\n `expire`\n )\n VALUES\n ('{$pclass->getEid()}',\n '{$pclass->getId()}',\n '{$pclass->getType()}',\n '{$pclass->getDescription()}',\n '{$pclass->getMonths()}',\n '{$pclass->getInterestRate()}',\n '{$pclass->getInvoiceFee()}',\n '{$pclass->getStartFee()}',\n '{$pclass->getMinAmount()}',\n '{$pclass->getCountry()}',\n '{$pclass->getExpire()}')\"", ",", "$", "this", "->", "link", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "Klarna_DatabaseException", "(", "'INSERT INTO query failed! ('", ".", "mysql_error", "(", ")", ".", "')'", ")", ";", "}", "}", "}", "}" ]
Save pclasses to database @param string $uri pclass uri @throws KlarnaException @return void
[ "Save", "pclasses", "to", "database" ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/pclasses/mysqlstorage.class.php#L266-L319
train
Subscribo/klarna-invoice-sdk-wrapped
src/pclasses/mysqlstorage.class.php
MySQLStorage.clear
public function clear($uri) { try { $this->splitURI($uri); unset($this->pclasses); $this->connect(); mysql_query( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}`", $this->link ); } catch(Exception $e) { throw new Klarna_DatabaseException( $e->getMessage(), $e->getCode() ); } }
php
public function clear($uri) { try { $this->splitURI($uri); unset($this->pclasses); $this->connect(); mysql_query( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}`", $this->link ); } catch(Exception $e) { throw new Klarna_DatabaseException( $e->getMessage(), $e->getCode() ); } }
[ "public", "function", "clear", "(", "$", "uri", ")", "{", "try", "{", "$", "this", "->", "splitURI", "(", "$", "uri", ")", ";", "unset", "(", "$", "this", "->", "pclasses", ")", ";", "$", "this", "->", "connect", "(", ")", ";", "mysql_query", "(", "\"DELETE FROM `{$this->dbName}`.`{$this->dbTable}`\"", ",", "$", "this", "->", "link", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Klarna_DatabaseException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "}" ]
Clear the pclasses @param string $uri pclass uri @throws KlarnaException @return void
[ "Clear", "the", "pclasses" ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/pclasses/mysqlstorage.class.php#L329-L345
train
eureka-framework/component-orm
src/Orm/Console/Generator.php
Generator.help
public function help() { $style = new Eurekon\Style(' *** RUN - HELP ***'); Eurekon\Out::std($style->color('fg', Eurekon\Style::COLOR_GREEN)->get()); Eurekon\Out::std(''); $help = new Eurekon\Help('...', true); $help->addArgument('', 'directory', 'Config directory to inspect for config file', true, true); $help->addArgument('', 'namespace', 'Config namespace (default: global.database)', true, false); $help->addArgument('', 'db', 'Database config name', true, false); $help->addArgument('', 'item', 'Config name in config file to generate.', true, false); $help->display(); }
php
public function help() { $style = new Eurekon\Style(' *** RUN - HELP ***'); Eurekon\Out::std($style->color('fg', Eurekon\Style::COLOR_GREEN)->get()); Eurekon\Out::std(''); $help = new Eurekon\Help('...', true); $help->addArgument('', 'directory', 'Config directory to inspect for config file', true, true); $help->addArgument('', 'namespace', 'Config namespace (default: global.database)', true, false); $help->addArgument('', 'db', 'Database config name', true, false); $help->addArgument('', 'item', 'Config name in config file to generate.', true, false); $help->display(); }
[ "public", "function", "help", "(", ")", "{", "$", "style", "=", "new", "Eurekon", "\\", "Style", "(", "' *** RUN - HELP ***'", ")", ";", "Eurekon", "\\", "Out", "::", "std", "(", "$", "style", "->", "color", "(", "'fg'", ",", "Eurekon", "\\", "Style", "::", "COLOR_GREEN", ")", "->", "get", "(", ")", ")", ";", "Eurekon", "\\", "Out", "::", "std", "(", "''", ")", ";", "$", "help", "=", "new", "Eurekon", "\\", "Help", "(", "'...'", ",", "true", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'directory'", ",", "'Config directory to inspect for config file'", ",", "true", ",", "true", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'namespace'", ",", "'Config namespace (default: global.database)'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'db'", ",", "'Database config name'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'item'", ",", "'Config name in config file to generate.'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "display", "(", ")", ";", "}" ]
Help method. @return void
[ "Help", "method", "." ]
bce48121d26c4e923534f9dc70da597634184316
https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Console/Generator.php#L43-L56
train
eureka-framework/component-orm
src/Orm/Console/Generator.php
Generator.run
public function run() { $argument = Eurekon\Argument::getInstance(); $directory = (string) $argument->get('directory'); $configName = (string) $argument->get('item'); $configNamespace = (string) $argument->get('namespace', null, 'global.database'); $dbName = (string) $argument->get('db'); //~ Init db connection $container = Container::getInstance(); $config = $container->get('config'); Database::getInstance()->setConfig($config->get($configNamespace)); $directory = realpath(trim(rtrim($directory, '\\'))); $file = $directory . DIRECTORY_SEPARATOR . 'orm.yml'; if (!is_readable($file)) { throw new \LogicException('Configuration file for ORM not available!'); } $yaml = new Yaml(); $data = $yaml->load($file); $directory = $directory . DIRECTORY_SEPARATOR . $data['orm']['directory']; $namespace = $data['orm']['namespace']; if (!is_dir($directory) && !mkdir($directory, 0764, true)) { throw new \RuntimeException('Cannot created output directory! (dir:' . $directory . ')'); } $configs = $this->findConfigs($file, $data, $configName, true); $builder = new Builder(); $builder->setDatabase(Database::get($dbName)); $builder->setNamespace($namespace); $builder->setDirectory($directory); $builder->build($configs); }
php
public function run() { $argument = Eurekon\Argument::getInstance(); $directory = (string) $argument->get('directory'); $configName = (string) $argument->get('item'); $configNamespace = (string) $argument->get('namespace', null, 'global.database'); $dbName = (string) $argument->get('db'); //~ Init db connection $container = Container::getInstance(); $config = $container->get('config'); Database::getInstance()->setConfig($config->get($configNamespace)); $directory = realpath(trim(rtrim($directory, '\\'))); $file = $directory . DIRECTORY_SEPARATOR . 'orm.yml'; if (!is_readable($file)) { throw new \LogicException('Configuration file for ORM not available!'); } $yaml = new Yaml(); $data = $yaml->load($file); $directory = $directory . DIRECTORY_SEPARATOR . $data['orm']['directory']; $namespace = $data['orm']['namespace']; if (!is_dir($directory) && !mkdir($directory, 0764, true)) { throw new \RuntimeException('Cannot created output directory! (dir:' . $directory . ')'); } $configs = $this->findConfigs($file, $data, $configName, true); $builder = new Builder(); $builder->setDatabase(Database::get($dbName)); $builder->setNamespace($namespace); $builder->setDirectory($directory); $builder->build($configs); }
[ "public", "function", "run", "(", ")", "{", "$", "argument", "=", "Eurekon", "\\", "Argument", "::", "getInstance", "(", ")", ";", "$", "directory", "=", "(", "string", ")", "$", "argument", "->", "get", "(", "'directory'", ")", ";", "$", "configName", "=", "(", "string", ")", "$", "argument", "->", "get", "(", "'item'", ")", ";", "$", "configNamespace", "=", "(", "string", ")", "$", "argument", "->", "get", "(", "'namespace'", ",", "null", ",", "'global.database'", ")", ";", "$", "dbName", "=", "(", "string", ")", "$", "argument", "->", "get", "(", "'db'", ")", ";", "//~ Init db connection", "$", "container", "=", "Container", "::", "getInstance", "(", ")", ";", "$", "config", "=", "$", "container", "->", "get", "(", "'config'", ")", ";", "Database", "::", "getInstance", "(", ")", "->", "setConfig", "(", "$", "config", "->", "get", "(", "$", "configNamespace", ")", ")", ";", "$", "directory", "=", "realpath", "(", "trim", "(", "rtrim", "(", "$", "directory", ",", "'\\\\'", ")", ")", ")", ";", "$", "file", "=", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "'orm.yml'", ";", "if", "(", "!", "is_readable", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Configuration file for ORM not available!'", ")", ";", "}", "$", "yaml", "=", "new", "Yaml", "(", ")", ";", "$", "data", "=", "$", "yaml", "->", "load", "(", "$", "file", ")", ";", "$", "directory", "=", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "data", "[", "'orm'", "]", "[", "'directory'", "]", ";", "$", "namespace", "=", "$", "data", "[", "'orm'", "]", "[", "'namespace'", "]", ";", "if", "(", "!", "is_dir", "(", "$", "directory", ")", "&&", "!", "mkdir", "(", "$", "directory", ",", "0764", ",", "true", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot created output directory! (dir:'", ".", "$", "directory", ".", "')'", ")", ";", "}", "$", "configs", "=", "$", "this", "->", "findConfigs", "(", "$", "file", ",", "$", "data", ",", "$", "configName", ",", "true", ")", ";", "$", "builder", "=", "new", "Builder", "(", ")", ";", "$", "builder", "->", "setDatabase", "(", "Database", "::", "get", "(", "$", "dbName", ")", ")", ";", "$", "builder", "->", "setNamespace", "(", "$", "namespace", ")", ";", "$", "builder", "->", "setDirectory", "(", "$", "directory", ")", ";", "$", "builder", "->", "build", "(", "$", "configs", ")", ";", "}" ]
Run method. @return void
[ "Run", "method", "." ]
bce48121d26c4e923534f9dc70da597634184316
https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Console/Generator.php#L63-L100
train
eureka-framework/component-orm
src/Orm/Console/Generator.php
Generator.findConfigs
protected function findConfigs($currentFile, array $data, $configName = '', $doLoadJoins = false) { $configs = array(); $data = $this->replace($currentFile, $data); foreach ($data['configs'] as $name => $config) { if (!empty($configName) && $name !== $configName) { continue; } if ($doLoadJoins) { $this->loadJoins($currentFile, $config, $data); } else { $config['joins'] = array(); } $configs[] = new Config($config, $data['orm']); } if (!$doLoadJoins) { $configs = array_shift($configs); } return $configs; }
php
protected function findConfigs($currentFile, array $data, $configName = '', $doLoadJoins = false) { $configs = array(); $data = $this->replace($currentFile, $data); foreach ($data['configs'] as $name => $config) { if (!empty($configName) && $name !== $configName) { continue; } if ($doLoadJoins) { $this->loadJoins($currentFile, $config, $data); } else { $config['joins'] = array(); } $configs[] = new Config($config, $data['orm']); } if (!$doLoadJoins) { $configs = array_shift($configs); } return $configs; }
[ "protected", "function", "findConfigs", "(", "$", "currentFile", ",", "array", "$", "data", ",", "$", "configName", "=", "''", ",", "$", "doLoadJoins", "=", "false", ")", "{", "$", "configs", "=", "array", "(", ")", ";", "$", "data", "=", "$", "this", "->", "replace", "(", "$", "currentFile", ",", "$", "data", ")", ";", "foreach", "(", "$", "data", "[", "'configs'", "]", "as", "$", "name", "=>", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "configName", ")", "&&", "$", "name", "!==", "$", "configName", ")", "{", "continue", ";", "}", "if", "(", "$", "doLoadJoins", ")", "{", "$", "this", "->", "loadJoins", "(", "$", "currentFile", ",", "$", "config", ",", "$", "data", ")", ";", "}", "else", "{", "$", "config", "[", "'joins'", "]", "=", "array", "(", ")", ";", "}", "$", "configs", "[", "]", "=", "new", "Config", "(", "$", "config", ",", "$", "data", "[", "'orm'", "]", ")", ";", "}", "if", "(", "!", "$", "doLoadJoins", ")", "{", "$", "configs", "=", "array_shift", "(", "$", "configs", ")", ";", "}", "return", "$", "configs", ";", "}" ]
Find configs. @param string $currentFile @param array $data @param string $configName Filter on name @param bool $doLoadJoins @return array|Config
[ "Find", "configs", "." ]
bce48121d26c4e923534f9dc70da597634184316
https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Console/Generator.php#L111-L137
train
eureka-framework/component-orm
src/Orm/Console/Generator.php
Generator.loadJoins
protected function loadJoins($currentFile, &$config, $data) { if (empty($config['joins']) || !is_array($config['joins'])) { $config['joins'] = array(); return $this; } foreach ($config['joins'] as $joinName => &$joinConfig) { $filename = $currentFile; if (isset($joinConfig['file']) && 'this' !== $joinConfig['file']) { $filename = str_replace('EKA_ROOT', EKA_ROOT, $joinConfig['file']); $yaml = new Yaml(); $data = $yaml->load($filename); } $joinConfig['class'] = $this->findConfigs($filename, $data, $joinName); } return $this; }
php
protected function loadJoins($currentFile, &$config, $data) { if (empty($config['joins']) || !is_array($config['joins'])) { $config['joins'] = array(); return $this; } foreach ($config['joins'] as $joinName => &$joinConfig) { $filename = $currentFile; if (isset($joinConfig['file']) && 'this' !== $joinConfig['file']) { $filename = str_replace('EKA_ROOT', EKA_ROOT, $joinConfig['file']); $yaml = new Yaml(); $data = $yaml->load($filename); } $joinConfig['class'] = $this->findConfigs($filename, $data, $joinName); } return $this; }
[ "protected", "function", "loadJoins", "(", "$", "currentFile", ",", "&", "$", "config", ",", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "config", "[", "'joins'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'joins'", "]", ")", ")", "{", "$", "config", "[", "'joins'", "]", "=", "array", "(", ")", ";", "return", "$", "this", ";", "}", "foreach", "(", "$", "config", "[", "'joins'", "]", "as", "$", "joinName", "=>", "&", "$", "joinConfig", ")", "{", "$", "filename", "=", "$", "currentFile", ";", "if", "(", "isset", "(", "$", "joinConfig", "[", "'file'", "]", ")", "&&", "'this'", "!==", "$", "joinConfig", "[", "'file'", "]", ")", "{", "$", "filename", "=", "str_replace", "(", "'EKA_ROOT'", ",", "EKA_ROOT", ",", "$", "joinConfig", "[", "'file'", "]", ")", ";", "$", "yaml", "=", "new", "Yaml", "(", ")", ";", "$", "data", "=", "$", "yaml", "->", "load", "(", "$", "filename", ")", ";", "}", "$", "joinConfig", "[", "'class'", "]", "=", "$", "this", "->", "findConfigs", "(", "$", "filename", ",", "$", "data", ",", "$", "joinName", ")", ";", "}", "return", "$", "this", ";", "}" ]
Load joined configs. @param string $currentFile @param array $config Current config @param array $data Global current config data @return self
[ "Load", "joined", "configs", "." ]
bce48121d26c4e923534f9dc70da597634184316
https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Console/Generator.php#L147-L168
train
asaokamei/ScoreSql
src/Builder/BuildWhere.php
BuildWhere.buildColRelVal
protected function buildColRelVal( $where ) { $rel = $where[ 'rel' ]; $col = $where[ 'col' ]; $val = $where[ 'val' ]; if ( $rel == 'EQ' ) { // EQ: equal to another column (i.e. val is an identifier.) $val = $this->quote( $val ); $rel = '='; } else { $val = $this->formWhereVal( $val ); } // normal case. compose where like col = val $col = $this->formWhereCol( $col ); $where = trim( "{$col} {$rel} {$val}" ) . ' '; return $where; }
php
protected function buildColRelVal( $where ) { $rel = $where[ 'rel' ]; $col = $where[ 'col' ]; $val = $where[ 'val' ]; if ( $rel == 'EQ' ) { // EQ: equal to another column (i.e. val is an identifier.) $val = $this->quote( $val ); $rel = '='; } else { $val = $this->formWhereVal( $val ); } // normal case. compose where like col = val $col = $this->formWhereCol( $col ); $where = trim( "{$col} {$rel} {$val}" ) . ' '; return $where; }
[ "protected", "function", "buildColRelVal", "(", "$", "where", ")", "{", "$", "rel", "=", "$", "where", "[", "'rel'", "]", ";", "$", "col", "=", "$", "where", "[", "'col'", "]", ";", "$", "val", "=", "$", "where", "[", "'val'", "]", ";", "if", "(", "$", "rel", "==", "'EQ'", ")", "{", "// EQ: equal to another column (i.e. val is an identifier.)", "$", "val", "=", "$", "this", "->", "quote", "(", "$", "val", ")", ";", "$", "rel", "=", "'='", ";", "}", "else", "{", "$", "val", "=", "$", "this", "->", "formWhereVal", "(", "$", "val", ")", ";", "}", "// normal case. compose where like col = val", "$", "col", "=", "$", "this", "->", "formWhereCol", "(", "$", "col", ")", ";", "$", "where", "=", "trim", "(", "\"{$col} {$rel} {$val}\"", ")", ".", "' '", ";", "return", "$", "where", ";", "}" ]
for normal case where condition, like col = val @param array $where @return string
[ "for", "normal", "case", "where", "condition", "like", "col", "=", "val" ]
f1fce28476629e98b3c4c1216859c7f5309de7a1
https://github.com/asaokamei/ScoreSql/blob/f1fce28476629e98b3c4c1216859c7f5309de7a1/src/Builder/BuildWhere.php#L150-L167
train
kkthek/diqa-util
src/Util/Configuration/ConfigLoader.php
ConfigLoader.loadEnv
public function loadEnv() { $ed = $this->loadEnvDefault(); $ej = $this->loadEnvJson(); if(!$ed && !$ej ) { $msg = "No configuration files found."; $this->error($msg); die($msg); } }
php
public function loadEnv() { $ed = $this->loadEnvDefault(); $ej = $this->loadEnvJson(); if(!$ed && !$ej ) { $msg = "No configuration files found."; $this->error($msg); die($msg); } }
[ "public", "function", "loadEnv", "(", ")", "{", "$", "ed", "=", "$", "this", "->", "loadEnvDefault", "(", ")", ";", "$", "ej", "=", "$", "this", "->", "loadEnvJson", "(", ")", ";", "if", "(", "!", "$", "ed", "&&", "!", "$", "ej", ")", "{", "$", "msg", "=", "\"No configuration files found.\"", ";", "$", "this", "->", "error", "(", "$", "msg", ")", ";", "die", "(", "$", "msg", ")", ";", "}", "}" ]
loads env-default.json and then env.json
[ "loads", "env", "-", "default", ".", "json", "and", "then", "env", ".", "json" ]
df35d16403b5dbf0f7570daded6cfa26814ae7e0
https://github.com/kkthek/diqa-util/blob/df35d16403b5dbf0f7570daded6cfa26814ae7e0/src/Util/Configuration/ConfigLoader.php#L80-L89
train
heiglandreas/OrgHeiglFileFinder
src/FileFinder.php
FileFinder.find
public function find() { $this->getFileList()->clear(); foreach ($this->searchLocations as $location) { if (! is_dir($location)) { continue; } $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($location)); foreach ($iterator as $file) { if (! $this->filter($file)) { continue; } $this->getFileList()->add($file); } } return $this->getFileList(); }
php
public function find() { $this->getFileList()->clear(); foreach ($this->searchLocations as $location) { if (! is_dir($location)) { continue; } $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($location)); foreach ($iterator as $file) { if (! $this->filter($file)) { continue; } $this->getFileList()->add($file); } } return $this->getFileList(); }
[ "public", "function", "find", "(", ")", "{", "$", "this", "->", "getFileList", "(", ")", "->", "clear", "(", ")", ";", "foreach", "(", "$", "this", "->", "searchLocations", "as", "$", "location", ")", "{", "if", "(", "!", "is_dir", "(", "$", "location", ")", ")", "{", "continue", ";", "}", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "location", ")", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "filter", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "getFileList", "(", ")", "->", "add", "(", "$", "file", ")", ";", "}", "}", "return", "$", "this", "->", "getFileList", "(", ")", ";", "}" ]
Do the actual searching @return FileListInterface[]
[ "Do", "the", "actual", "searching" ]
189d15b95bec7dc186ef73681463c104831234d8
https://github.com/heiglandreas/OrgHeiglFileFinder/blob/189d15b95bec7dc186ef73681463c104831234d8/src/FileFinder.php#L113-L130
train
heiglandreas/OrgHeiglFileFinder
src/FileFinder.php
FileFinder.filter
public function filter(\SPLFileInfo $file) { foreach ($this->filterlist as $filter) { if (! $filter->filter($file)) { return false; } } return true; }
php
public function filter(\SPLFileInfo $file) { foreach ($this->filterlist as $filter) { if (! $filter->filter($file)) { return false; } } return true; }
[ "public", "function", "filter", "(", "\\", "SPLFileInfo", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "filterlist", "as", "$", "filter", ")", "{", "if", "(", "!", "$", "filter", "->", "filter", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Filter the file @param SPLFileInfo $file @return bool
[ "Filter", "the", "file" ]
189d15b95bec7dc186ef73681463c104831234d8
https://github.com/heiglandreas/OrgHeiglFileFinder/blob/189d15b95bec7dc186ef73681463c104831234d8/src/FileFinder.php#L139-L147
train
AnonymPHP/Anonym-HttpFoundation
Request.php
Request.file
public function file($name = '', $uploadDir = UPLOAD) { if (isset($_FILES[$name])) { $file = new FileUpload($_FILES[$name], $uploadDir); return $file; } else { throw new FileNotUploadedException(sprintf('Your %s file is not uploaded yet', $name)); } }
php
public function file($name = '', $uploadDir = UPLOAD) { if (isset($_FILES[$name])) { $file = new FileUpload($_FILES[$name], $uploadDir); return $file; } else { throw new FileNotUploadedException(sprintf('Your %s file is not uploaded yet', $name)); } }
[ "public", "function", "file", "(", "$", "name", "=", "''", ",", "$", "uploadDir", "=", "UPLOAD", ")", "{", "if", "(", "isset", "(", "$", "_FILES", "[", "$", "name", "]", ")", ")", "{", "$", "file", "=", "new", "FileUpload", "(", "$", "_FILES", "[", "$", "name", "]", ",", "$", "uploadDir", ")", ";", "return", "$", "file", ";", "}", "else", "{", "throw", "new", "FileNotUploadedException", "(", "sprintf", "(", "'Your %s file is not uploaded yet'", ",", "$", "name", ")", ")", ";", "}", "}" ]
upload a file with input name and uplaod dir, //////////////// $name parameter must be a string and it is has to be exists $uploadDir must be an instance of string and it's must be a dir. @param string $name the name of upload input @param string $uploadDir the dir to upload file @throws FileNotUploadedException @return FileUpload
[ "upload", "a", "file", "with", "input", "name", "and", "uplaod", "dir" ]
943e5f40f45bc2e11a4b9e1d22c6583c31dc4317
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Request.php#L164-L172
train
AnonymPHP/Anonym-HttpFoundation
Request.php
Request.findDocumentRootInScriptFileName
private function findDocumentRootInScriptFileName() { $filename = $this->server->get('SCRIPT_FILENAME') ?: false; if (false === $filename) { return false; } $parse = explode('/', $filename); $count = count($parse); if ($count && $count > 1) { $path = array_slice($parse, 0, $count-1); return $this->removeLastSlash(join('/', $path)); } else { return '/'; } }
php
private function findDocumentRootInScriptFileName() { $filename = $this->server->get('SCRIPT_FILENAME') ?: false; if (false === $filename) { return false; } $parse = explode('/', $filename); $count = count($parse); if ($count && $count > 1) { $path = array_slice($parse, 0, $count-1); return $this->removeLastSlash(join('/', $path)); } else { return '/'; } }
[ "private", "function", "findDocumentRootInScriptFileName", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "server", "->", "get", "(", "'SCRIPT_FILENAME'", ")", "?", ":", "false", ";", "if", "(", "false", "===", "$", "filename", ")", "{", "return", "false", ";", "}", "$", "parse", "=", "explode", "(", "'/'", ",", "$", "filename", ")", ";", "$", "count", "=", "count", "(", "$", "parse", ")", ";", "if", "(", "$", "count", "&&", "$", "count", ">", "1", ")", "{", "$", "path", "=", "array_slice", "(", "$", "parse", ",", "0", ",", "$", "count", "-", "1", ")", ";", "return", "$", "this", "->", "removeLastSlash", "(", "join", "(", "'/'", ",", "$", "path", ")", ")", ";", "}", "else", "{", "return", "'/'", ";", "}", "}" ]
find document root in server script filename @return bool|string
[ "find", "document", "root", "in", "server", "script", "filename" ]
943e5f40f45bc2e11a4b9e1d22c6583c31dc4317
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Request.php#L267-L283
train
AnonymPHP/Anonym-HttpFoundation
Request.php
Request.getBaseUri
public function getBaseUri() { if ('' !== $qs = $this->getQueryString()) { $qs = '?' . $qs; } return $this->getSchemeAndHost() . $this->getRequestUri() . $qs; }
php
public function getBaseUri() { if ('' !== $qs = $this->getQueryString()) { $qs = '?' . $qs; } return $this->getSchemeAndHost() . $this->getRequestUri() . $qs; }
[ "public", "function", "getBaseUri", "(", ")", "{", "if", "(", "''", "!==", "$", "qs", "=", "$", "this", "->", "getQueryString", "(", ")", ")", "{", "$", "qs", "=", "'?'", ".", "$", "qs", ";", "}", "return", "$", "this", "->", "getSchemeAndHost", "(", ")", ".", "$", "this", "->", "getRequestUri", "(", ")", ".", "$", "qs", ";", "}" ]
find the scheme and request uri @return string
[ "find", "the", "scheme", "and", "request", "uri" ]
943e5f40f45bc2e11a4b9e1d22c6583c31dc4317
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Request.php#L373-L380
train
AnonymPHP/Anonym-HttpFoundation
Request.php
Request.segment
public function segment($segment) { $segments = $this->segments; return isset($segments[$segment - 1]) ? $segments[$segment - 1] : false; }
php
public function segment($segment) { $segments = $this->segments; return isset($segments[$segment - 1]) ? $segments[$segment - 1] : false; }
[ "public", "function", "segment", "(", "$", "segment", ")", "{", "$", "segments", "=", "$", "this", "->", "segments", ";", "return", "isset", "(", "$", "segments", "[", "$", "segment", "-", "1", "]", ")", "?", "$", "segments", "[", "$", "segment", "-", "1", "]", ":", "false", ";", "}" ]
get url segment @param int $segment @return string|bool
[ "get", "url", "segment" ]
943e5f40f45bc2e11a4b9e1d22c6583c31dc4317
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Request.php#L455-L460
train
dms-org/common.structure
src/DateTime/DateTime.php
DateTime.inTimezone
public function inTimezone(string $timeZoneId) : TimezonedDateTime { return new TimezonedDateTime( \DateTimeImmutable::createFromFormat( self::DISPLAY_FORMAT, $this->format(self::DISPLAY_FORMAT), new \DateTimeZone($timeZoneId) ) ); }
php
public function inTimezone(string $timeZoneId) : TimezonedDateTime { return new TimezonedDateTime( \DateTimeImmutable::createFromFormat( self::DISPLAY_FORMAT, $this->format(self::DISPLAY_FORMAT), new \DateTimeZone($timeZoneId) ) ); }
[ "public", "function", "inTimezone", "(", "string", "$", "timeZoneId", ")", ":", "TimezonedDateTime", "{", "return", "new", "TimezonedDateTime", "(", "\\", "DateTimeImmutable", "::", "createFromFormat", "(", "self", "::", "DISPLAY_FORMAT", ",", "$", "this", "->", "format", "(", "self", "::", "DISPLAY_FORMAT", ")", ",", "new", "\\", "DateTimeZone", "(", "$", "timeZoneId", ")", ")", ")", ";", "}" ]
Returns the current date time as if it were in the supplied timezone @param string $timeZoneId @return TimezonedDateTime
[ "Returns", "the", "current", "date", "time", "as", "if", "it", "were", "in", "the", "supplied", "timezone" ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/DateTime.php#L153-L162
train
enikeishik/ufoframework
src/Ufo/Modules/View.php
View.render
public function render(): string { $obLevel = ob_get_level(); ob_start(); extract($this->data); $templatesPath = $this->config->projectPath . $this->config->templatesPath; $package = ''; $template = $this->template; if (!empty($this->section->module)) { $package = $this->section->module->vendor . '/' . $this->section->module->name; } elseif (!empty($this->widget->vendor)) { if (!empty($this->widget->module)) { $package = $this->widget->vendor . '/' . $this->widget->module; $template = 'widget' . $this->widget->name; } else { $package = $this->widget->vendor . '/widgets'; $template = $this->widget->name; } } $templatePath = $this->findTemplate($templatesPath, $package, $template); if (!file_exists($templatePath)) { $templatePath = $this->findTemplate($templatesPath, '', $this->template); } try { include $templatePath; } catch (\Throwable $e) { $this->handleRenderException($e, $obLevel); } return ob_get_clean(); }
php
public function render(): string { $obLevel = ob_get_level(); ob_start(); extract($this->data); $templatesPath = $this->config->projectPath . $this->config->templatesPath; $package = ''; $template = $this->template; if (!empty($this->section->module)) { $package = $this->section->module->vendor . '/' . $this->section->module->name; } elseif (!empty($this->widget->vendor)) { if (!empty($this->widget->module)) { $package = $this->widget->vendor . '/' . $this->widget->module; $template = 'widget' . $this->widget->name; } else { $package = $this->widget->vendor . '/widgets'; $template = $this->widget->name; } } $templatePath = $this->findTemplate($templatesPath, $package, $template); if (!file_exists($templatePath)) { $templatePath = $this->findTemplate($templatesPath, '', $this->template); } try { include $templatePath; } catch (\Throwable $e) { $this->handleRenderException($e, $obLevel); } return ob_get_clean(); }
[ "public", "function", "render", "(", ")", ":", "string", "{", "$", "obLevel", "=", "ob_get_level", "(", ")", ";", "ob_start", "(", ")", ";", "extract", "(", "$", "this", "->", "data", ")", ";", "$", "templatesPath", "=", "$", "this", "->", "config", "->", "projectPath", ".", "$", "this", "->", "config", "->", "templatesPath", ";", "$", "package", "=", "''", ";", "$", "template", "=", "$", "this", "->", "template", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "section", "->", "module", ")", ")", "{", "$", "package", "=", "$", "this", "->", "section", "->", "module", "->", "vendor", ".", "'/'", ".", "$", "this", "->", "section", "->", "module", "->", "name", ";", "}", "elseif", "(", "!", "empty", "(", "$", "this", "->", "widget", "->", "vendor", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "widget", "->", "module", ")", ")", "{", "$", "package", "=", "$", "this", "->", "widget", "->", "vendor", ".", "'/'", ".", "$", "this", "->", "widget", "->", "module", ";", "$", "template", "=", "'widget'", ".", "$", "this", "->", "widget", "->", "name", ";", "}", "else", "{", "$", "package", "=", "$", "this", "->", "widget", "->", "vendor", ".", "'/widgets'", ";", "$", "template", "=", "$", "this", "->", "widget", "->", "name", ";", "}", "}", "$", "templatePath", "=", "$", "this", "->", "findTemplate", "(", "$", "templatesPath", ",", "$", "package", ",", "$", "template", ")", ";", "if", "(", "!", "file_exists", "(", "$", "templatePath", ")", ")", "{", "$", "templatePath", "=", "$", "this", "->", "findTemplate", "(", "$", "templatesPath", ",", "''", ",", "$", "this", "->", "template", ")", ";", "}", "try", "{", "include", "$", "templatePath", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "this", "->", "handleRenderException", "(", "$", "e", ",", "$", "obLevel", ")", ";", "}", "return", "ob_get_clean", "(", ")", ";", "}" ]
Generate output. @return string
[ "Generate", "output", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Modules/View.php#L129-L163
train
enikeishik/ufoframework
src/Ufo/Modules/View.php
View.findTemplate
protected function findTemplate(string $templatesPath, string $package, string $templateName): string { if (!empty($package)) { // /templates/default/vendor/module/template.php $templatePath = $templatesPath . $this->config->templatesDefault . '/' . strtolower($package) . '/' . str_replace('.', '/', $templateName) . $this->extension; if (file_exists($templatePath)) { return $templatePath; } } // /templates/default/template.php $templatePath = $templatesPath . $this->config->templatesDefault . '/' . str_replace('.', '/', $templateName) . $this->extension; return $templatePath; }
php
protected function findTemplate(string $templatesPath, string $package, string $templateName): string { if (!empty($package)) { // /templates/default/vendor/module/template.php $templatePath = $templatesPath . $this->config->templatesDefault . '/' . strtolower($package) . '/' . str_replace('.', '/', $templateName) . $this->extension; if (file_exists($templatePath)) { return $templatePath; } } // /templates/default/template.php $templatePath = $templatesPath . $this->config->templatesDefault . '/' . str_replace('.', '/', $templateName) . $this->extension; return $templatePath; }
[ "protected", "function", "findTemplate", "(", "string", "$", "templatesPath", ",", "string", "$", "package", ",", "string", "$", "templateName", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "package", ")", ")", "{", "// /templates/default/vendor/module/template.php", "$", "templatePath", "=", "$", "templatesPath", ".", "$", "this", "->", "config", "->", "templatesDefault", ".", "'/'", ".", "strtolower", "(", "$", "package", ")", ".", "'/'", ".", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "templateName", ")", ".", "$", "this", "->", "extension", ";", "if", "(", "file_exists", "(", "$", "templatePath", ")", ")", "{", "return", "$", "templatePath", ";", "}", "}", "// /templates/default/template.php", "$", "templatePath", "=", "$", "templatesPath", ".", "$", "this", "->", "config", "->", "templatesDefault", ".", "'/'", ".", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "templateName", ")", ".", "$", "this", "->", "extension", ";", "return", "$", "templatePath", ";", "}" ]
Find full path for requested template. Returned path may not exists. @param string $templatesPath @param string $package @param string $templateName @return string
[ "Find", "full", "path", "for", "requested", "template", ".", "Returned", "path", "may", "not", "exists", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Modules/View.php#L194-L214
train
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Builder.php
Builder.withGlobalScope
public function withGlobalScope( $identifier, $scope ) { $this->scopes[$identifier] = $scope; if ( method_exists( $scope, 'extend' ) ) $scope->extend( $this ); return $this; }
php
public function withGlobalScope( $identifier, $scope ) { $this->scopes[$identifier] = $scope; if ( method_exists( $scope, 'extend' ) ) $scope->extend( $this ); return $this; }
[ "public", "function", "withGlobalScope", "(", "$", "identifier", ",", "$", "scope", ")", "{", "$", "this", "->", "scopes", "[", "$", "identifier", "]", "=", "$", "scope", ";", "if", "(", "method_exists", "(", "$", "scope", ",", "'extend'", ")", ")", "$", "scope", "->", "extend", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Register a new global scope. @param string $identifier @param Closure $scope @return $this
[ "Register", "a", "new", "global", "scope", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Builder.php#L100-L108
train
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Builder.php
Builder.whereCountQuery
protected function whereCountQuery( QueryBuilder $query, $operator = '>=', $count = 1, $boolean = 'and' ) { if ( is_numeric( $count ) ) { $count = new Expression( $count ); } $this->query->addBinding( $query->getBindings(), 'where' ); return $this->where( new Expression( '(' . $query->toSql() . ')' ), $operator, $count, $boolean ); }
php
protected function whereCountQuery( QueryBuilder $query, $operator = '>=', $count = 1, $boolean = 'and' ) { if ( is_numeric( $count ) ) { $count = new Expression( $count ); } $this->query->addBinding( $query->getBindings(), 'where' ); return $this->where( new Expression( '(' . $query->toSql() . ')' ), $operator, $count, $boolean ); }
[ "protected", "function", "whereCountQuery", "(", "QueryBuilder", "$", "query", ",", "$", "operator", "=", "'>='", ",", "$", "count", "=", "1", ",", "$", "boolean", "=", "'and'", ")", "{", "if", "(", "is_numeric", "(", "$", "count", ")", ")", "{", "$", "count", "=", "new", "Expression", "(", "$", "count", ")", ";", "}", "$", "this", "->", "query", "->", "addBinding", "(", "$", "query", "->", "getBindings", "(", ")", ",", "'where'", ")", ";", "return", "$", "this", "->", "where", "(", "new", "Expression", "(", "'('", ".", "$", "query", "->", "toSql", "(", ")", ".", "')'", ")", ",", "$", "operator", ",", "$", "count", ",", "$", "boolean", ")", ";", "}" ]
Add a sub query count clause to the query. @param Builder $query @param string $operator @param int $count @param string $boolean @return $this
[ "Add", "a", "sub", "query", "count", "clause", "to", "the", "query", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Builder.php#L1000-L1010
train
PenoaksDev/Milky-Framework
src/Milky/Database/Eloquent/Builder.php
Builder.mergeModelDefinedRelationConstraints
public function mergeModelDefinedRelationConstraints( Builder $relation ) { $removedScopes = $relation->removedScopes(); $relationQuery = $relation->getQuery(); // Here we have some relation query and the original relation. We need to copy over any // where clauses that the developer may have put in the relation definition function. // We need to remove any global scopes that the developer already removed as well. return $this->withoutGlobalScopes( $removedScopes )->mergeWheres( $relationQuery->wheres, $relationQuery->getBindings() ); }
php
public function mergeModelDefinedRelationConstraints( Builder $relation ) { $removedScopes = $relation->removedScopes(); $relationQuery = $relation->getQuery(); // Here we have some relation query and the original relation. We need to copy over any // where clauses that the developer may have put in the relation definition function. // We need to remove any global scopes that the developer already removed as well. return $this->withoutGlobalScopes( $removedScopes )->mergeWheres( $relationQuery->wheres, $relationQuery->getBindings() ); }
[ "public", "function", "mergeModelDefinedRelationConstraints", "(", "Builder", "$", "relation", ")", "{", "$", "removedScopes", "=", "$", "relation", "->", "removedScopes", "(", ")", ";", "$", "relationQuery", "=", "$", "relation", "->", "getQuery", "(", ")", ";", "// Here we have some relation query and the original relation. We need to copy over any", "// where clauses that the developer may have put in the relation definition function.", "// We need to remove any global scopes that the developer already removed as well.", "return", "$", "this", "->", "withoutGlobalScopes", "(", "$", "removedScopes", ")", "->", "mergeWheres", "(", "$", "relationQuery", "->", "wheres", ",", "$", "relationQuery", "->", "getBindings", "(", ")", ")", ";", "}" ]
Merge the constraints from a relation query to the current query. @param Builder $relation @return Builder|static
[ "Merge", "the", "constraints", "from", "a", "relation", "query", "to", "the", "current", "query", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Builder.php#L1018-L1028
train
bkstg/schedule-bundle
EventListener/InvitationAutoAcceptListener.php
InvitationAutoAcceptListener.prePersist
public function prePersist(LifecycleEventArgs $args): void { // Only act on invitation objects. $invitation = $args->getObject(); if (!$invitation instanceof Invitation) { return; } // If the event author is the invitee accept the invitation. $event = $invitation->getEvent(); if ($event->getAuthor() == $invitation->getInvitee()) { $invitation->setResponse(Invitation::RESPONSE_ACCEPT); } }
php
public function prePersist(LifecycleEventArgs $args): void { // Only act on invitation objects. $invitation = $args->getObject(); if (!$invitation instanceof Invitation) { return; } // If the event author is the invitee accept the invitation. $event = $invitation->getEvent(); if ($event->getAuthor() == $invitation->getInvitee()) { $invitation->setResponse(Invitation::RESPONSE_ACCEPT); } }
[ "public", "function", "prePersist", "(", "LifecycleEventArgs", "$", "args", ")", ":", "void", "{", "// Only act on invitation objects.", "$", "invitation", "=", "$", "args", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "invitation", "instanceof", "Invitation", ")", "{", "return", ";", "}", "// If the event author is the invitee accept the invitation.", "$", "event", "=", "$", "invitation", "->", "getEvent", "(", ")", ";", "if", "(", "$", "event", "->", "getAuthor", "(", ")", "==", "$", "invitation", "->", "getInvitee", "(", ")", ")", "{", "$", "invitation", "->", "setResponse", "(", "Invitation", "::", "RESPONSE_ACCEPT", ")", ";", "}", "}" ]
Checks the invitation author and accepts if they match. @param LifecycleEventArgs $args The lifecycle arguments. @return void
[ "Checks", "the", "invitation", "author", "and", "accepts", "if", "they", "match", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/EventListener/InvitationAutoAcceptListener.php#L26-L39
train
mossphp/moss-storage
Moss/Storage/Query/WriteQuery.php
WriteQuery.checkIfEntityExists
protected function checkIfEntityExists() { $query = new ReadQuery($this->connection, $this->model, $this->factory, $this->accessor, $this->dispatcher); foreach ($this->model->primaryFields() as $field) { $value = $this->accessor->getPropertyValue($this->instance, $field->name()); if ($value === null) { return false; } $query->where($field->name(), $value, '=', 'and'); } return $query->count() > 0; }
php
protected function checkIfEntityExists() { $query = new ReadQuery($this->connection, $this->model, $this->factory, $this->accessor, $this->dispatcher); foreach ($this->model->primaryFields() as $field) { $value = $this->accessor->getPropertyValue($this->instance, $field->name()); if ($value === null) { return false; } $query->where($field->name(), $value, '=', 'and'); } return $query->count() > 0; }
[ "protected", "function", "checkIfEntityExists", "(", ")", "{", "$", "query", "=", "new", "ReadQuery", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "model", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "foreach", "(", "$", "this", "->", "model", "->", "primaryFields", "(", ")", "as", "$", "field", ")", "{", "$", "value", "=", "$", "this", "->", "accessor", "->", "getPropertyValue", "(", "$", "this", "->", "instance", ",", "$", "field", "->", "name", "(", ")", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "return", "false", ";", "}", "$", "query", "->", "where", "(", "$", "field", "->", "name", "(", ")", ",", "$", "value", ",", "'='", ",", "'and'", ")", ";", "}", "return", "$", "query", "->", "count", "(", ")", ">", "0", ";", "}" ]
Returns true if entity exists database @return int
[ "Returns", "true", "if", "entity", "exists", "database" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/WriteQuery.php#L138-L153
train
joegreen88/zf1-component-validate
src/Zend/Validate/File/Size.php
Zend_Validate_File_Size.setMax
public function setMax($max) { if (!is_string($max) && !is_numeric($max)) { throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $this->_fromByteString($max); $min = $this->getMin(true); if (($min !== null) && ($max < $min)) { throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum filesize, but " . "$max < $min"); } $this->_max = $max; return $this; }
php
public function setMax($max) { if (!is_string($max) && !is_numeric($max)) { throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $this->_fromByteString($max); $min = $this->getMin(true); if (($min !== null) && ($max < $min)) { throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum filesize, but " . "$max < $min"); } $this->_max = $max; return $this; }
[ "public", "function", "setMax", "(", "$", "max", ")", "{", "if", "(", "!", "is_string", "(", "$", "max", ")", "&&", "!", "is_numeric", "(", "$", "max", ")", ")", "{", "throw", "new", "Zend_Validate_Exception", "(", "'Invalid options to validator provided'", ")", ";", "}", "$", "max", "=", "(", "integer", ")", "$", "this", "->", "_fromByteString", "(", "$", "max", ")", ";", "$", "min", "=", "$", "this", "->", "getMin", "(", "true", ")", ";", "if", "(", "(", "$", "min", "!==", "null", ")", "&&", "(", "$", "max", "<", "$", "min", ")", ")", "{", "throw", "new", "Zend_Validate_Exception", "(", "\"The maximum must be greater than or equal to the minimum filesize, but \"", ".", "\"$max < $min\"", ")", ";", "}", "$", "this", "->", "_max", "=", "$", "max", ";", "return", "$", "this", ";", "}" ]
Sets the maximum filesize @param integer $max The maximum filesize @throws Zend_Validate_Exception When max is smaller than min @return Zend_Validate_StringLength Provides a fluent interface
[ "Sets", "the", "maximum", "filesize" ]
88d9ea016f73d48ff0ba7d06ecbbf28951fd279e
https://github.com/joegreen88/zf1-component-validate/blob/88d9ea016f73d48ff0ba7d06ecbbf28951fd279e/src/Zend/Validate/File/Size.php#L223-L240
train
squareproton/Bond
src/Bond/Normality/Php.php
Php.isValid
public function isValid( &$errors = null, $throwException = false ) { // open pipe $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'), ); $process = proc_open('php -l', $descriptorSpec, $pipes); if (!is_resource($process)) { throw new \Exception('Could not open PHP'); } fwrite($pipes[0], $this->php); fclose($pipes[0]); $errors = stream_get_contents($pipes[2]); fclose($pipes[2]); $returnValue = proc_close($process); if( $throwException && $returnValue !== 0 ) { throw new BadPhpException($errors); } return $returnValue === 0; }
php
public function isValid( &$errors = null, $throwException = false ) { // open pipe $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'), ); $process = proc_open('php -l', $descriptorSpec, $pipes); if (!is_resource($process)) { throw new \Exception('Could not open PHP'); } fwrite($pipes[0], $this->php); fclose($pipes[0]); $errors = stream_get_contents($pipes[2]); fclose($pipes[2]); $returnValue = proc_close($process); if( $throwException && $returnValue !== 0 ) { throw new BadPhpException($errors); } return $returnValue === 0; }
[ "public", "function", "isValid", "(", "&", "$", "errors", "=", "null", ",", "$", "throwException", "=", "false", ")", "{", "// open pipe", "$", "descriptorSpec", "=", "array", "(", "0", "=>", "array", "(", "'pipe'", ",", "'r'", ")", ",", "1", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ",", "2", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ",", ")", ";", "$", "process", "=", "proc_open", "(", "'php -l'", ",", "$", "descriptorSpec", ",", "$", "pipes", ")", ";", "if", "(", "!", "is_resource", "(", "$", "process", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Could not open PHP'", ")", ";", "}", "fwrite", "(", "$", "pipes", "[", "0", "]", ",", "$", "this", "->", "php", ")", ";", "fclose", "(", "$", "pipes", "[", "0", "]", ")", ";", "$", "errors", "=", "stream_get_contents", "(", "$", "pipes", "[", "2", "]", ")", ";", "fclose", "(", "$", "pipes", "[", "2", "]", ")", ";", "$", "returnValue", "=", "proc_close", "(", "$", "process", ")", ";", "if", "(", "$", "throwException", "&&", "$", "returnValue", "!==", "0", ")", "{", "throw", "new", "BadPhpException", "(", "$", "errors", ")", ";", "}", "return", "$", "returnValue", "===", "0", ";", "}" ]
Run Php through lint checker @retrun bool Is the passed php valid
[ "Run", "Php", "through", "lint", "checker" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/Php.php#L42-L71
train
squareproton/Bond
src/Bond/Normality/Php.php
Php.varExport
public static function varExport( $var, $indent = 0, $dontIndentFirstLine = true ) { $export = var_export( $var, true ); // array ( => array ( $export = preg_replace( '/^array \\(/', 'array(', $export ); // UPPERCASE null(s) seem to bother me for some reason. I've no idea why. if( $export === 'NULL' ) { $export = 'null'; } // // change the default indent from 2 to 4 $export = str_replace( ' ', ' ', $export ); $lines = explode( "\n", $export ); $i = $dontIndentFirstLine ? 1 : 0; $indent = \str_repeat( ' ', $indent ); for( ; $i<count($lines); $i++) { $lines[$i] = $indent.$lines[$i]; } return implode( "\n", $lines ); }
php
public static function varExport( $var, $indent = 0, $dontIndentFirstLine = true ) { $export = var_export( $var, true ); // array ( => array ( $export = preg_replace( '/^array \\(/', 'array(', $export ); // UPPERCASE null(s) seem to bother me for some reason. I've no idea why. if( $export === 'NULL' ) { $export = 'null'; } // // change the default indent from 2 to 4 $export = str_replace( ' ', ' ', $export ); $lines = explode( "\n", $export ); $i = $dontIndentFirstLine ? 1 : 0; $indent = \str_repeat( ' ', $indent ); for( ; $i<count($lines); $i++) { $lines[$i] = $indent.$lines[$i]; } return implode( "\n", $lines ); }
[ "public", "static", "function", "varExport", "(", "$", "var", ",", "$", "indent", "=", "0", ",", "$", "dontIndentFirstLine", "=", "true", ")", "{", "$", "export", "=", "var_export", "(", "$", "var", ",", "true", ")", ";", "// array ( => array (", "$", "export", "=", "preg_replace", "(", "'/^array \\\\(/'", ",", "'array('", ",", "$", "export", ")", ";", "// UPPERCASE null(s) seem to bother me for some reason. I've no idea why.", "if", "(", "$", "export", "===", "'NULL'", ")", "{", "$", "export", "=", "'null'", ";", "}", "//", "// change the default indent from 2 to 4", "$", "export", "=", "str_replace", "(", "' '", ",", "' '", ",", "$", "export", ")", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "export", ")", ";", "$", "i", "=", "$", "dontIndentFirstLine", "?", "1", ":", "0", ";", "$", "indent", "=", "\\", "str_repeat", "(", "' '", ",", "$", "indent", ")", ";", "for", "(", ";", "$", "i", "<", "count", "(", "$", "lines", ")", ";", "$", "i", "++", ")", "{", "$", "lines", "[", "$", "i", "]", "=", "$", "indent", ".", "$", "lines", "[", "$", "i", "]", ";", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "lines", ")", ";", "}" ]
Return a string which is a php-parsable representation of a variable @param mixed $var @param int $indent @param bool $dontIndentFirstLine @return string
[ "Return", "a", "string", "which", "is", "a", "php", "-", "parsable", "representation", "of", "a", "variable" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/Php.php#L80-L107
train
hiqsol-attic/composer-extension-plugin
src/Helper.php
Helper.exportVar
public static function exportVar($value) { $closures = self::collectClosures($value); $res = var_export($value, true); if (!empty($closures)) { $subs = []; foreach ($closures as $key => $closure) { $subs["'" . $key . "'"] = self::dumpClosure($closure); } $res = strtr($res, $subs); } return $res; }
php
public static function exportVar($value) { $closures = self::collectClosures($value); $res = var_export($value, true); if (!empty($closures)) { $subs = []; foreach ($closures as $key => $closure) { $subs["'" . $key . "'"] = self::dumpClosure($closure); } $res = strtr($res, $subs); } return $res; }
[ "public", "static", "function", "exportVar", "(", "$", "value", ")", "{", "$", "closures", "=", "self", "::", "collectClosures", "(", "$", "value", ")", ";", "$", "res", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "closures", ")", ")", "{", "$", "subs", "=", "[", "]", ";", "foreach", "(", "$", "closures", "as", "$", "key", "=>", "$", "closure", ")", "{", "$", "subs", "[", "\"'\"", ".", "$", "key", ".", "\"'\"", "]", "=", "self", "::", "dumpClosure", "(", "$", "closure", ")", ";", "}", "$", "res", "=", "strtr", "(", "$", "res", ",", "$", "subs", ")", ";", "}", "return", "$", "res", ";", "}" ]
Returns a parsable string representation of given value. In contrast to var_dump outputs Closures as PHP code. @param mixed $value @return string
[ "Returns", "a", "parsable", "string", "representation", "of", "given", "value", ".", "In", "contrast", "to", "var_dump", "outputs", "Closures", "as", "PHP", "code", "." ]
3e4a5384ca368f43debe277c606846e4299d2bf4
https://github.com/hiqsol-attic/composer-extension-plugin/blob/3e4a5384ca368f43debe277c606846e4299d2bf4/src/Helper.php#L90-L103
train
hiqsol-attic/composer-extension-plugin
src/Helper.php
Helper.collectClosures
private static function collectClosures(&$input) { static $closureNo = 1; $closures = []; if (is_array($input)) { foreach ($input as &$value) { if (is_array($value) || $value instanceof Closure) { $closures = array_merge($closures, self::collectClosures($value)); } } } elseif ($input instanceof Closure) { $closureNo++; $key = "--==<<[[((Closure#$closureNo))]]>>==--"; $closures[$key] = $input; $input = $key; } return $closures; }
php
private static function collectClosures(&$input) { static $closureNo = 1; $closures = []; if (is_array($input)) { foreach ($input as &$value) { if (is_array($value) || $value instanceof Closure) { $closures = array_merge($closures, self::collectClosures($value)); } } } elseif ($input instanceof Closure) { $closureNo++; $key = "--==<<[[((Closure#$closureNo))]]>>==--"; $closures[$key] = $input; $input = $key; } return $closures; }
[ "private", "static", "function", "collectClosures", "(", "&", "$", "input", ")", "{", "static", "$", "closureNo", "=", "1", ";", "$", "closures", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "input", ")", ")", "{", "foreach", "(", "$", "input", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "||", "$", "value", "instanceof", "Closure", ")", "{", "$", "closures", "=", "array_merge", "(", "$", "closures", ",", "self", "::", "collectClosures", "(", "$", "value", ")", ")", ";", "}", "}", "}", "elseif", "(", "$", "input", "instanceof", "Closure", ")", "{", "$", "closureNo", "++", ";", "$", "key", "=", "\"--==<<[[((Closure#$closureNo))]]>>==--\"", ";", "$", "closures", "[", "$", "key", "]", "=", "$", "input", ";", "$", "input", "=", "$", "key", ";", "}", "return", "$", "closures", ";", "}" ]
Collects closures from given input. Substitutes closures with a tag. @param mixed $input will be changed @return array array of found closures
[ "Collects", "closures", "from", "given", "input", ".", "Substitutes", "closures", "with", "a", "tag", "." ]
3e4a5384ca368f43debe277c606846e4299d2bf4
https://github.com/hiqsol-attic/composer-extension-plugin/blob/3e4a5384ca368f43debe277c606846e4299d2bf4/src/Helper.php#L111-L128
train
WideFocus/Feed-Writer
src/ExtractFieldLabelsTrait.php
ExtractFieldLabelsTrait.extractFieldLabels
protected function extractFieldLabels( WriterFieldInterface ...$fields ): array { return array_map( function (WriterFieldInterface $field) : string { return $field->getLabel(); }, $fields ); }
php
protected function extractFieldLabels( WriterFieldInterface ...$fields ): array { return array_map( function (WriterFieldInterface $field) : string { return $field->getLabel(); }, $fields ); }
[ "protected", "function", "extractFieldLabels", "(", "WriterFieldInterface", "...", "$", "fields", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "WriterFieldInterface", "$", "field", ")", ":", "string", "{", "return", "$", "field", "->", "getLabel", "(", ")", ";", "}", ",", "$", "fields", ")", ";", "}" ]
Extract labels from fields. @param WriterFieldInterface[] ...$fields @return string[]
[ "Extract", "labels", "from", "fields", "." ]
c2698394645c75db06962e5e9d638f0cabe69fe3
https://github.com/WideFocus/Feed-Writer/blob/c2698394645c75db06962e5e9d638f0cabe69fe3/src/ExtractFieldLabelsTrait.php#L18-L27
train
phospr/DoubleEntryBundle
Model/VendorHandler.php
VendorHandler.createVendor
public function createVendor($name = null) { $vendor = new $this->vendorFqcn($name); $vendor->setOrganization($this->oh->getOrganization()); return $vendor; }
php
public function createVendor($name = null) { $vendor = new $this->vendorFqcn($name); $vendor->setOrganization($this->oh->getOrganization()); return $vendor; }
[ "public", "function", "createVendor", "(", "$", "name", "=", "null", ")", "{", "$", "vendor", "=", "new", "$", "this", "->", "vendorFqcn", "(", "$", "name", ")", ";", "$", "vendor", "->", "setOrganization", "(", "$", "this", "->", "oh", "->", "getOrganization", "(", ")", ")", ";", "return", "$", "vendor", ";", "}" ]
Create new Vendor @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @param string $name @return Vendor
[ "Create", "new", "Vendor" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/VendorHandler.php#L72-L78
train
phospr/DoubleEntryBundle
Model/VendorHandler.php
VendorHandler.findVendorForName
public function findVendorForName($name) { return $this->em ->getRepository($this->vendorFqcn) ->findOneBy(array( 'name' => $name, 'organization' => $this->oh->getOrganization() )) ; }
php
public function findVendorForName($name) { return $this->em ->getRepository($this->vendorFqcn) ->findOneBy(array( 'name' => $name, 'organization' => $this->oh->getOrganization() )) ; }
[ "public", "function", "findVendorForName", "(", "$", "name", ")", "{", "return", "$", "this", "->", "em", "->", "getRepository", "(", "$", "this", "->", "vendorFqcn", ")", "->", "findOneBy", "(", "array", "(", "'name'", "=>", "$", "name", ",", "'organization'", "=>", "$", "this", "->", "oh", "->", "getOrganization", "(", ")", ")", ")", ";", "}" ]
Find Vendor for name @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @param string $name @return Vendor
[ "Find", "Vendor", "for", "name" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/VendorHandler.php#L90-L99
train
phospr/DoubleEntryBundle
Model/VendorHandler.php
VendorHandler.findVendorForSlug
public function findVendorForSlug($slug) { return $this->em ->getRepository($this->vendorFqcn) ->findOneBy(array( 'slug' => $slug, 'organization' => $this->oh->getOrganization() )) ; }
php
public function findVendorForSlug($slug) { return $this->em ->getRepository($this->vendorFqcn) ->findOneBy(array( 'slug' => $slug, 'organization' => $this->oh->getOrganization() )) ; }
[ "public", "function", "findVendorForSlug", "(", "$", "slug", ")", "{", "return", "$", "this", "->", "em", "->", "getRepository", "(", "$", "this", "->", "vendorFqcn", ")", "->", "findOneBy", "(", "array", "(", "'slug'", "=>", "$", "slug", ",", "'organization'", "=>", "$", "this", "->", "oh", "->", "getOrganization", "(", ")", ")", ")", ";", "}" ]
Find Vendor for slug @author Tom Haskins-Vaughan <[email protected]> @since 0.8.0 @param string $slug @return Vendor
[ "Find", "Vendor", "for", "slug" ]
d9c421f30922b461483731983c59beb26047fb7f
https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/VendorHandler.php#L111-L120
train
johnkrovitch/Sam
Filter/Compass/CompassFilter.php
CompassFilter.run
public function run(array $sources, array $destinations) { $updatedSources = []; foreach ($sources as $source) { // remove .scss extension and add .css extension $css = $this->getCacheDir().$source->getBasename('.scss').'.css'; $this->addNotification('compiling '.$source.' to '.$css); // compilation start $process = new Process($command = $this->buildCommandString($source)); $process->run(); if (!$process->isSuccessful()) { throw new Exception( 'An error has occurred during the compass compile task : "'.$process->getErrorOutput()."" .' (running "'.$command.'")' ); } // add css file to destination files $updatedSources[] = $css; } if (count($updatedSources)) { // compilation success notification $this->addNotification('scss files compilation success'); } return $updatedSources; }
php
public function run(array $sources, array $destinations) { $updatedSources = []; foreach ($sources as $source) { // remove .scss extension and add .css extension $css = $this->getCacheDir().$source->getBasename('.scss').'.css'; $this->addNotification('compiling '.$source.' to '.$css); // compilation start $process = new Process($command = $this->buildCommandString($source)); $process->run(); if (!$process->isSuccessful()) { throw new Exception( 'An error has occurred during the compass compile task : "'.$process->getErrorOutput()."" .' (running "'.$command.'")' ); } // add css file to destination files $updatedSources[] = $css; } if (count($updatedSources)) { // compilation success notification $this->addNotification('scss files compilation success'); } return $updatedSources; }
[ "public", "function", "run", "(", "array", "$", "sources", ",", "array", "$", "destinations", ")", "{", "$", "updatedSources", "=", "[", "]", ";", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "// remove .scss extension and add .css extension", "$", "css", "=", "$", "this", "->", "getCacheDir", "(", ")", ".", "$", "source", "->", "getBasename", "(", "'.scss'", ")", ".", "'.css'", ";", "$", "this", "->", "addNotification", "(", "'compiling '", ".", "$", "source", ".", "' to '", ".", "$", "css", ")", ";", "// compilation start", "$", "process", "=", "new", "Process", "(", "$", "command", "=", "$", "this", "->", "buildCommandString", "(", "$", "source", ")", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'An error has occurred during the compass compile task : \"'", ".", "$", "process", "->", "getErrorOutput", "(", ")", ".", "\"\"", ".", "' (running \"'", ".", "$", "command", ".", "'\")'", ")", ";", "}", "// add css file to destination files", "$", "updatedSources", "[", "]", "=", "$", "css", ";", "}", "if", "(", "count", "(", "$", "updatedSources", ")", ")", "{", "// compilation success notification", "$", "this", "->", "addNotification", "(", "'scss files compilation success'", ")", ";", "}", "return", "$", "updatedSources", ";", "}" ]
Compile scss file into css file via compass. @param SplFileInfo[] $sources @param SplFileInfo[] $destinations @return SplFileInfo[] @throws Exception
[ "Compile", "scss", "file", "into", "css", "file", "via", "compass", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Filter/Compass/CompassFilter.php#L20-L49
train
johnkrovitch/Sam
Filter/Compass/CompassFilter.php
CompassFilter.checkRequirements
public function checkRequirements() { $process = new Process($this->getBin().' version'); $process->run(); if (!$process->isSuccessful()) { throw new Exception('compass is not found at '.$this->getBin().'. '.$process->getErrorOutput()); } }
php
public function checkRequirements() { $process = new Process($this->getBin().' version'); $process->run(); if (!$process->isSuccessful()) { throw new Exception('compass is not found at '.$this->getBin().'. '.$process->getErrorOutput()); } }
[ "public", "function", "checkRequirements", "(", ")", "{", "$", "process", "=", "new", "Process", "(", "$", "this", "->", "getBin", "(", ")", ".", "' version'", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'compass is not found at '", ".", "$", "this", "->", "getBin", "(", ")", ".", "'. '", ".", "$", "process", "->", "getErrorOutput", "(", ")", ")", ";", "}", "}" ]
Check that compass is installed and available. @throws Exception
[ "Check", "that", "compass", "is", "installed", "and", "available", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Filter/Compass/CompassFilter.php#L56-L64
train
johnkrovitch/Sam
Filter/Compass/CompassFilter.php
CompassFilter.buildCommandString
protected function buildCommandString($source) { $commandPattern = '%s %s %s %s %s'; $command = sprintf( // pattern $commandPattern, // compass binary path $this->getBin(), // compass command 'compile', // sources $source->getRealPath(), // destination file '--css-dir='.$this->getCacheDir(), // sass directory '--sass-dir='.$source->getPath() ); return $command; }
php
protected function buildCommandString($source) { $commandPattern = '%s %s %s %s %s'; $command = sprintf( // pattern $commandPattern, // compass binary path $this->getBin(), // compass command 'compile', // sources $source->getRealPath(), // destination file '--css-dir='.$this->getCacheDir(), // sass directory '--sass-dir='.$source->getPath() ); return $command; }
[ "protected", "function", "buildCommandString", "(", "$", "source", ")", "{", "$", "commandPattern", "=", "'%s %s %s %s %s'", ";", "$", "command", "=", "sprintf", "(", "// pattern", "$", "commandPattern", ",", "// compass binary path", "$", "this", "->", "getBin", "(", ")", ",", "// compass command", "'compile'", ",", "// sources", "$", "source", "->", "getRealPath", "(", ")", ",", "// destination file", "'--css-dir='", ".", "$", "this", "->", "getCacheDir", "(", ")", ",", "// sass directory", "'--sass-dir='", ".", "$", "source", "->", "getPath", "(", ")", ")", ";", "return", "$", "command", ";", "}" ]
Build the compass compile command line. @param SplFileInfo $source @return string
[ "Build", "the", "compass", "compile", "command", "line", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Filter/Compass/CompassFilter.php#L96-L115
train
aztech-labs/skwal
src/Table.php
Table.getColumn
public function getColumn($name, $alias = '') { $column = new DerivedColumn($name, $alias); return $column->setTable($this); }
php
public function getColumn($name, $alias = '') { $column = new DerivedColumn($name, $alias); return $column->setTable($this); }
[ "public", "function", "getColumn", "(", "$", "name", ",", "$", "alias", "=", "''", ")", "{", "$", "column", "=", "new", "DerivedColumn", "(", "$", "name", ",", "$", "alias", ")", ";", "return", "$", "column", "->", "setTable", "(", "$", "this", ")", ";", "}" ]
Returns a column object correlated to the current table. @param string $name Name of the column to return. @param string $alias Alias to use on the column. @return DerivedColumn
[ "Returns", "a", "column", "object", "correlated", "to", "the", "current", "table", "." ]
cf637c5ddb69f6579ba28a61af9c39639081dc16
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Table.php#L94-L99
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.getAllRecords
public function getAllRecords() { /* @var DataObject $recordType */ $recordType = $this->getRecordType(); $all = $recordType::get()->filterByCallBack(function (DataObject $obj) { return $obj->canView(); }); return new PaginatedList($all, $this->request); }
php
public function getAllRecords() { /* @var DataObject $recordType */ $recordType = $this->getRecordType(); $all = $recordType::get()->filterByCallBack(function (DataObject $obj) { return $obj->canView(); }); return new PaginatedList($all, $this->request); }
[ "public", "function", "getAllRecords", "(", ")", "{", "/* @var DataObject $recordType */", "$", "recordType", "=", "$", "this", "->", "getRecordType", "(", ")", ";", "$", "all", "=", "$", "recordType", "::", "get", "(", ")", "->", "filterByCallBack", "(", "function", "(", "DataObject", "$", "obj", ")", "{", "return", "$", "obj", "->", "canView", "(", ")", ";", "}", ")", ";", "return", "new", "PaginatedList", "(", "$", "all", ",", "$", "this", "->", "request", ")", ";", "}" ]
Gets all the records and returns them, paginated @return PaginatedList @throws \Exception
[ "Gets", "all", "the", "records", "and", "returns", "them", "paginated" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L163-L172
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.getEditableRecords
public function getEditableRecords() { $recordType = $this->getRecordType(); $all = $recordType::get()->filterByCallBack(function (DataObject $obj) { return $obj->canEdit(); }); return new PaginatedList($all, $this->request); }
php
public function getEditableRecords() { $recordType = $this->getRecordType(); $all = $recordType::get()->filterByCallBack(function (DataObject $obj) { return $obj->canEdit(); }); return new PaginatedList($all, $this->request); }
[ "public", "function", "getEditableRecords", "(", ")", "{", "$", "recordType", "=", "$", "this", "->", "getRecordType", "(", ")", ";", "$", "all", "=", "$", "recordType", "::", "get", "(", ")", "->", "filterByCallBack", "(", "function", "(", "DataObject", "$", "obj", ")", "{", "return", "$", "obj", "->", "canEdit", "(", ")", ";", "}", ")", ";", "return", "new", "PaginatedList", "(", "$", "all", ",", "$", "this", "->", "request", ")", ";", "}" ]
Gets all editable records and returns them, paginated @return PaginatedList @throws \Exception
[ "Gets", "all", "editable", "records", "and", "returns", "them", "paginated" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L180-L188
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.create_new
public function create_new($request) { if (!$this->canCreate()) { return $this->httpError(403, "You do not have permission to create new " . $this->getPluralName()); } $this->addCrumb('Create new ' . $this->getSingularName()); return $this->customise(['Form' => $this->CreationForm()]); }
php
public function create_new($request) { if (!$this->canCreate()) { return $this->httpError(403, "You do not have permission to create new " . $this->getPluralName()); } $this->addCrumb('Create new ' . $this->getSingularName()); return $this->customise(['Form' => $this->CreationForm()]); }
[ "public", "function", "create_new", "(", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "canCreate", "(", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "403", ",", "\"You do not have permission to create new \"", ".", "$", "this", "->", "getPluralName", "(", ")", ")", ";", "}", "$", "this", "->", "addCrumb", "(", "'Create new '", ".", "$", "this", "->", "getSingularName", "(", ")", ")", ";", "return", "$", "this", "->", "customise", "(", "[", "'Form'", "=>", "$", "this", "->", "CreationForm", "(", ")", "]", ")", ";", "}" ]
URL method to create a new record @param HTTPRequest $request @return \SilverStripe\View\ViewableData_Customised|void @throws HTTPResponse_Exception
[ "URL", "method", "to", "create", "a", "new", "record" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L241-L248
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.CreationForm
public function CreationForm() { /** @var FieldList $fields */ $fields = singleton($this->getRecordType())->getFrontEndFields(); $fields->push(new HiddenField('ID')); $form = new Form( $this, 'CreationForm', $fields, new FieldList( new FormAction('doSave', 'Save'), new FormAction('doCancel', 'Cancel') )); return $form; }
php
public function CreationForm() { /** @var FieldList $fields */ $fields = singleton($this->getRecordType())->getFrontEndFields(); $fields->push(new HiddenField('ID')); $form = new Form( $this, 'CreationForm', $fields, new FieldList( new FormAction('doSave', 'Save'), new FormAction('doCancel', 'Cancel') )); return $form; }
[ "public", "function", "CreationForm", "(", ")", "{", "/** @var FieldList $fields */", "$", "fields", "=", "singleton", "(", "$", "this", "->", "getRecordType", "(", ")", ")", "->", "getFrontEndFields", "(", ")", ";", "$", "fields", "->", "push", "(", "new", "HiddenField", "(", "'ID'", ")", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'CreationForm'", ",", "$", "fields", ",", "new", "FieldList", "(", "new", "FormAction", "(", "'doSave'", ",", "'Save'", ")", ",", "new", "FormAction", "(", "'doCancel'", ",", "'Cancel'", ")", ")", ")", ";", "return", "$", "form", ";", "}" ]
Scaffolds a form for creating managed data types @return Form
[ "Scaffolds", "a", "form", "for", "creating", "managed", "data", "types" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L295-L309
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.doSave
public function doSave($data, $form) { $recordType = $this->getRecordType(); $record = $recordType::create(); $form->saveInto($record); $record->write(); $this->redirect($this->Link()); }
php
public function doSave($data, $form) { $recordType = $this->getRecordType(); $record = $recordType::create(); $form->saveInto($record); $record->write(); $this->redirect($this->Link()); }
[ "public", "function", "doSave", "(", "$", "data", ",", "$", "form", ")", "{", "$", "recordType", "=", "$", "this", "->", "getRecordType", "(", ")", ";", "$", "record", "=", "$", "recordType", "::", "create", "(", ")", ";", "$", "form", "->", "saveInto", "(", "$", "record", ")", ";", "$", "record", "->", "write", "(", ")", ";", "$", "this", "->", "redirect", "(", "$", "this", "->", "Link", "(", ")", ")", ";", "}" ]
Function for saving the form
[ "Function", "for", "saving", "the", "form" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L314-L321
train
twohill/silverstripe-nestedcontrollers
code/NestedCollectionController.php
NestedCollectionController.AlphabetPages
public function AlphabetPages() { $query = new SQLSelect(); $pages = new ArrayList(); $sortOn = $this->config()->sort_on; //Build an SQL query to get all the letters that people start with $query->select(array("Left($sortOn, 1) AS Letter")); $query->from($this->getRecordType()); $query->groupBy(array('Letter')); $lettersFound = $query->execute()->column(); $pages->push( new ArrayData( array( 'Letter' => 'All', 'Link' => $this->Link(), 'CurrentBool' => !isset($_GET['Letter']), ) ) ); foreach (array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0' ) as $letter) { $letterFound = in_array($letter, $lettersFound); $pages->push( new ArrayData( array( 'Letter' => $letter, 'Link' => $letterFound ? $this->Link() . '?letter=' . $letter : false, 'CurrentBool' => isset($_GET['letter']) && $_GET['letter'] == $letter, ) ) ); } return $pages; }
php
public function AlphabetPages() { $query = new SQLSelect(); $pages = new ArrayList(); $sortOn = $this->config()->sort_on; //Build an SQL query to get all the letters that people start with $query->select(array("Left($sortOn, 1) AS Letter")); $query->from($this->getRecordType()); $query->groupBy(array('Letter')); $lettersFound = $query->execute()->column(); $pages->push( new ArrayData( array( 'Letter' => 'All', 'Link' => $this->Link(), 'CurrentBool' => !isset($_GET['Letter']), ) ) ); foreach (array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0' ) as $letter) { $letterFound = in_array($letter, $lettersFound); $pages->push( new ArrayData( array( 'Letter' => $letter, 'Link' => $letterFound ? $this->Link() . '?letter=' . $letter : false, 'CurrentBool' => isset($_GET['letter']) && $_GET['letter'] == $letter, ) ) ); } return $pages; }
[ "public", "function", "AlphabetPages", "(", ")", "{", "$", "query", "=", "new", "SQLSelect", "(", ")", ";", "$", "pages", "=", "new", "ArrayList", "(", ")", ";", "$", "sortOn", "=", "$", "this", "->", "config", "(", ")", "->", "sort_on", ";", "//Build an SQL query to get all the letters that people start with", "$", "query", "->", "select", "(", "array", "(", "\"Left($sortOn, 1) AS Letter\"", ")", ")", ";", "$", "query", "->", "from", "(", "$", "this", "->", "getRecordType", "(", ")", ")", ";", "$", "query", "->", "groupBy", "(", "array", "(", "'Letter'", ")", ")", ";", "$", "lettersFound", "=", "$", "query", "->", "execute", "(", ")", "->", "column", "(", ")", ";", "$", "pages", "->", "push", "(", "new", "ArrayData", "(", "array", "(", "'Letter'", "=>", "'All'", ",", "'Link'", "=>", "$", "this", "->", "Link", "(", ")", ",", "'CurrentBool'", "=>", "!", "isset", "(", "$", "_GET", "[", "'Letter'", "]", ")", ",", ")", ")", ")", ";", "foreach", "(", "array", "(", "'A'", ",", "'B'", ",", "'C'", ",", "'D'", ",", "'E'", ",", "'F'", ",", "'G'", ",", "'H'", ",", "'I'", ",", "'J'", ",", "'K'", ",", "'L'", ",", "'M'", ",", "'N'", ",", "'O'", ",", "'P'", ",", "'Q'", ",", "'R'", ",", "'S'", ",", "'T'", ",", "'U'", ",", "'V'", ",", "'W'", ",", "'X'", ",", "'Y'", ",", "'Z'", ",", "'0'", ")", "as", "$", "letter", ")", "{", "$", "letterFound", "=", "in_array", "(", "$", "letter", ",", "$", "lettersFound", ")", ";", "$", "pages", "->", "push", "(", "new", "ArrayData", "(", "array", "(", "'Letter'", "=>", "$", "letter", ",", "'Link'", "=>", "$", "letterFound", "?", "$", "this", "->", "Link", "(", ")", ".", "'?letter='", ".", "$", "letter", ":", "false", ",", "'CurrentBool'", "=>", "isset", "(", "$", "_GET", "[", "'letter'", "]", ")", "&&", "$", "_GET", "[", "'letter'", "]", "==", "$", "letter", ",", ")", ")", ")", ";", "}", "return", "$", "pages", ";", "}" ]
Generates a ArrayList of anonymous objects that can be used to create an alphabet menu for all the items, linking only when there are items begining with the letter, and providing an indication of whether it is currently selected or not @return ArrayList
[ "Generates", "a", "ArrayList", "of", "anonymous", "objects", "that", "can", "be", "used", "to", "create", "an", "alphabet", "menu", "for", "all", "the", "items", "linking", "only", "when", "there", "are", "items", "begining", "with", "the", "letter", "and", "providing", "an", "indication", "of", "whether", "it", "is", "currently", "selected", "or", "not" ]
2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1
https://github.com/twohill/silverstripe-nestedcontrollers/blob/2fc263c31b7e23e2f768dc56f4f0df2912b6b3b1/code/NestedCollectionController.php#L390-L457
train
rawphp/RawSession
src/RawPHP/RawSession/Session.php
Session.removeHandler
public function removeHandler( IHandler $handler = NULL ) { if ( NULL !== $handler && $this->handler == $handler ) { $this->handler = NULL; } else { $this->handler = NULL; } }
php
public function removeHandler( IHandler $handler = NULL ) { if ( NULL !== $handler && $this->handler == $handler ) { $this->handler = NULL; } else { $this->handler = NULL; } }
[ "public", "function", "removeHandler", "(", "IHandler", "$", "handler", "=", "NULL", ")", "{", "if", "(", "NULL", "!==", "$", "handler", "&&", "$", "this", "->", "handler", "==", "$", "handler", ")", "{", "$", "this", "->", "handler", "=", "NULL", ";", "}", "else", "{", "$", "this", "->", "handler", "=", "NULL", ";", "}", "}" ]
Remove a handler from the session. @param IHandler $handler
[ "Remove", "a", "handler", "from", "the", "session", "." ]
1e410e1def1d6d61acfade3bd31478464c70aea3
https://github.com/rawphp/RawSession/blob/1e410e1def1d6d61acfade3bd31478464c70aea3/src/RawPHP/RawSession/Session.php#L281-L291
train
praxigento/mobi_mod_pv
Service/Batch/Transfer/Save.php
Save.readCsv
private function readCsv($fullPath) { $result = []; $entries = $this->hlpCsv->read($fullPath); foreach ($entries as $one) { $i=0; $fromId = $one[$i++]; $fromName = $one[$i++]; $toId = $one[$i++]; $toName = $one[$i++]; $volume = $one[$i++]; $item = new DItem(); $item->from = $fromId; $item->to = $toId; $item->value = $volume; $result[] = $item; } return $result; }
php
private function readCsv($fullPath) { $result = []; $entries = $this->hlpCsv->read($fullPath); foreach ($entries as $one) { $i=0; $fromId = $one[$i++]; $fromName = $one[$i++]; $toId = $one[$i++]; $toName = $one[$i++]; $volume = $one[$i++]; $item = new DItem(); $item->from = $fromId; $item->to = $toId; $item->value = $volume; $result[] = $item; } return $result; }
[ "private", "function", "readCsv", "(", "$", "fullPath", ")", "{", "$", "result", "=", "[", "]", ";", "$", "entries", "=", "$", "this", "->", "hlpCsv", "->", "read", "(", "$", "fullPath", ")", ";", "foreach", "(", "$", "entries", "as", "$", "one", ")", "{", "$", "i", "=", "0", ";", "$", "fromId", "=", "$", "one", "[", "$", "i", "++", "]", ";", "$", "fromName", "=", "$", "one", "[", "$", "i", "++", "]", ";", "$", "toId", "=", "$", "one", "[", "$", "i", "++", "]", ";", "$", "toName", "=", "$", "one", "[", "$", "i", "++", "]", ";", "$", "volume", "=", "$", "one", "[", "$", "i", "++", "]", ";", "$", "item", "=", "new", "DItem", "(", ")", ";", "$", "item", "->", "from", "=", "$", "fromId", ";", "$", "item", "->", "to", "=", "$", "toId", ";", "$", "item", "->", "value", "=", "$", "volume", ";", "$", "result", "[", "]", "=", "$", "item", ";", "}", "return", "$", "result", ";", "}" ]
Read & parse CSV file. @param string $fullPath @return DItem[]
[ "Read", "&", "parse", "CSV", "file", "." ]
d1540b7e94264527006e8b9fa68904a72a63928e
https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Service/Batch/Transfer/Save.php#L54-L73
train
cubicmushroom/valueobjects
src/Money/Money.php
Money.fromNative
public static function fromNative() { $args = func_get_args(); $amount = new Integer($args[0]); $currency = Currency::fromNative($args[1]); return new static($amount, $currency); }
php
public static function fromNative() { $args = func_get_args(); $amount = new Integer($args[0]); $currency = Currency::fromNative($args[1]); return new static($amount, $currency); }
[ "public", "static", "function", "fromNative", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "amount", "=", "new", "Integer", "(", "$", "args", "[", "0", "]", ")", ";", "$", "currency", "=", "Currency", "::", "fromNative", "(", "$", "args", "[", "1", "]", ")", ";", "return", "new", "static", "(", "$", "amount", ",", "$", "currency", ")", ";", "}" ]
Returns a Money object from native int amount and string currency code @param int $amount Amount expressed in the smallest units of $currency (e.g. cents) @param string $currency Currency code of the money object @return static
[ "Returns", "a", "Money", "object", "from", "native", "int", "amount", "and", "string", "currency", "code" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Money/Money.php#L28-L36
train
cubicmushroom/valueobjects
src/Money/Money.php
Money.sameValueAs
public function sameValueAs(ValueObjectInterface $money) { if (false === Util::classEquals($this, $money)) { return false; } return $this->getAmount()->sameValueAs($money->getAmount()) && $this->getCurrency()->sameValueAs($money->getCurrency()); }
php
public function sameValueAs(ValueObjectInterface $money) { if (false === Util::classEquals($this, $money)) { return false; } return $this->getAmount()->sameValueAs($money->getAmount()) && $this->getCurrency()->sameValueAs($money->getCurrency()); }
[ "public", "function", "sameValueAs", "(", "ValueObjectInterface", "$", "money", ")", "{", "if", "(", "false", "===", "Util", "::", "classEquals", "(", "$", "this", ",", "$", "money", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getAmount", "(", ")", "->", "sameValueAs", "(", "$", "money", "->", "getAmount", "(", ")", ")", "&&", "$", "this", "->", "getCurrency", "(", ")", "->", "sameValueAs", "(", "$", "money", "->", "getCurrency", "(", ")", ")", ";", "}" ]
Tells whether two Currency are equal by comparing their amount and currency @param ValueObjectInterface $money @return bool
[ "Tells", "whether", "two", "Currency", "are", "equal", "by", "comparing", "their", "amount", "and", "currency" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Money/Money.php#L57-L64
train
cubicmushroom/valueobjects
src/Money/Money.php
Money.add
public function add(Integer $quantity) { $amount = new Integer($this->getAmount()->toNative() + $quantity->toNative()); $result = new self($amount, $this->getCurrency()); return $result; }
php
public function add(Integer $quantity) { $amount = new Integer($this->getAmount()->toNative() + $quantity->toNative()); $result = new self($amount, $this->getCurrency()); return $result; }
[ "public", "function", "add", "(", "Integer", "$", "quantity", ")", "{", "$", "amount", "=", "new", "Integer", "(", "$", "this", "->", "getAmount", "(", ")", "->", "toNative", "(", ")", "+", "$", "quantity", "->", "toNative", "(", ")", ")", ";", "$", "result", "=", "new", "self", "(", "$", "amount", ",", "$", "this", "->", "getCurrency", "(", ")", ")", ";", "return", "$", "result", ";", "}" ]
Add an integer quantity to the amount and returns a new Money object. Use a negative quantity for subtraction. @param Integer $quantity Quantity to add @return Money
[ "Add", "an", "integer", "quantity", "to", "the", "amount", "and", "returns", "a", "new", "Money", "object", ".", "Use", "a", "negative", "quantity", "for", "subtraction", "." ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Money/Money.php#L95-L101
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/M2PQuery.php
M2PQuery.filterByPageId
public function filterByPageId($pageId = null, $comparison = null) { if (is_array($pageId)) { $useMinMax = false; if (isset($pageId['min'])) { $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($pageId['max'])) { $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId, $comparison); }
php
public function filterByPageId($pageId = null, $comparison = null) { if (is_array($pageId)) { $useMinMax = false; if (isset($pageId['min'])) { $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($pageId['max'])) { $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(M2PTableMap::COL_PAGE_ID, $pageId, $comparison); }
[ "public", "function", "filterByPageId", "(", "$", "pageId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "pageId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "pageId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "M2PTableMap", "::", "COL_PAGE_ID", ",", "$", "pageId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "pageId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "M2PTableMap", "::", "COL_PAGE_ID", ",", "$", "pageId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "M2PTableMap", "::", "COL_PAGE_ID", ",", "$", "pageId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the page_id column Example usage: <code> $query->filterByPageId(1234); // WHERE page_id = 1234 $query->filterByPageId(array(12, 34)); // WHERE page_id IN (12, 34) $query->filterByPageId(array('min' => 12)); // WHERE page_id > 12 </code> @see filterByPage() @param mixed $pageId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildM2PQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "page_id", "column" ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/M2PQuery.php#L337-L358
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/M2PQuery.php
M2PQuery.usePageQuery
public function usePageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPage($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Page', '\Attogram\SharedMedia\Orm\PageQuery'); }
php
public function usePageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPage($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Page', '\Attogram\SharedMedia\Orm\PageQuery'); }
[ "public", "function", "usePageQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinPage", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Page'", ",", "'\\Attogram\\SharedMedia\\Orm\\PageQuery'", ")", ";", "}" ]
Use the Page relation Page object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Attogram\SharedMedia\Orm\PageQuery A secondary query class using the current class as primary query
[ "Use", "the", "Page", "relation", "Page", "object" ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/M2PQuery.php#L507-L512
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.getInstance
public static function getInstance($name) { $key = self::_instanceKey($name); if (!isset(self::$_instances[$key])) { $dataSource = self::getDataAdapter(); if (is_null($dataSource)) { $data = array(); } else { $data = $dataSource->load($key); } $config = new self($data); /* @var $config Config */ $config->_root = $config; $config->_key = $key; self::$_instances[$key] = $config; } return self::$_instances[$key]; }
php
public static function getInstance($name) { $key = self::_instanceKey($name); if (!isset(self::$_instances[$key])) { $dataSource = self::getDataAdapter(); if (is_null($dataSource)) { $data = array(); } else { $data = $dataSource->load($key); } $config = new self($data); /* @var $config Config */ $config->_root = $config; $config->_key = $key; self::$_instances[$key] = $config; } return self::$_instances[$key]; }
[ "public", "static", "function", "getInstance", "(", "$", "name", ")", "{", "$", "key", "=", "self", "::", "_instanceKey", "(", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "_instances", "[", "$", "key", "]", ")", ")", "{", "$", "dataSource", "=", "self", "::", "getDataAdapter", "(", ")", ";", "if", "(", "is_null", "(", "$", "dataSource", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "}", "else", "{", "$", "data", "=", "$", "dataSource", "->", "load", "(", "$", "key", ")", ";", "}", "$", "config", "=", "new", "self", "(", "$", "data", ")", ";", "/* @var $config Config */", "$", "config", "->", "_root", "=", "$", "config", ";", "$", "config", "->", "_key", "=", "$", "key", ";", "self", "::", "$", "_instances", "[", "$", "key", "]", "=", "$", "config", ";", "}", "return", "self", "::", "$", "_instances", "[", "$", "key", "]", ";", "}" ]
Returns config instance @param string $name Config name @return Config
[ "Returns", "config", "instance" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L53-L73
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.newInstance
public static function newInstance($name, $data = null) { if (!is_array($data)) { $data = array(); } $config = self::getInstance($name); $config->_data = $data; return $config; }
php
public static function newInstance($name, $data = null) { if (!is_array($data)) { $data = array(); } $config = self::getInstance($name); $config->_data = $data; return $config; }
[ "public", "static", "function", "newInstance", "(", "$", "name", ",", "$", "data", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "}", "$", "config", "=", "self", "::", "getInstance", "(", "$", "name", ")", ";", "$", "config", "->", "_data", "=", "$", "data", ";", "return", "$", "config", ";", "}" ]
Shortcut for instance creation. @param string $name Config name @param array $data Config data @return Config
[ "Shortcut", "for", "instance", "creation", "." ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L83-L93
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.clearInstance
public static function clearInstance($name) { $key = self::_instanceKey($name); if (isset(self::$_instances[$key])) { unset(self::$_instances[$key]); } }
php
public static function clearInstance($name) { $key = self::_instanceKey($name); if (isset(self::$_instances[$key])) { unset(self::$_instances[$key]); } }
[ "public", "static", "function", "clearInstance", "(", "$", "name", ")", "{", "$", "key", "=", "self", "::", "_instanceKey", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "_instances", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "_instances", "[", "$", "key", "]", ")", ";", "}", "}" ]
Unloads config instance. @param string $name Config name @return null
[ "Unloads", "config", "instance", "." ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L102-L109
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.clearAll
public static function clearAll() { $names = array_keys(self::$_instances); foreach ($names as $name) { self::clearInstance($name); } }
php
public static function clearAll() { $names = array_keys(self::$_instances); foreach ($names as $name) { self::clearInstance($name); } }
[ "public", "static", "function", "clearAll", "(", ")", "{", "$", "names", "=", "array_keys", "(", "self", "::", "$", "_instances", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "self", "::", "clearInstance", "(", "$", "name", ")", ";", "}", "}" ]
Upload all configs data @return null
[ "Upload", "all", "configs", "data" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L116-L122
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.saveInstance
public static function saveInstance($name) { $adapter = self::getDataAdapter(); if (!is_null($adapter)) { $config = self::getInstance($name); $key = self::_instanceKey($name); $result = $adapter->save($key, $config); } else { $result = false; } return $result; }
php
public static function saveInstance($name) { $adapter = self::getDataAdapter(); if (!is_null($adapter)) { $config = self::getInstance($name); $key = self::_instanceKey($name); $result = $adapter->save($key, $config); } else { $result = false; } return $result; }
[ "public", "static", "function", "saveInstance", "(", "$", "name", ")", "{", "$", "adapter", "=", "self", "::", "getDataAdapter", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "adapter", ")", ")", "{", "$", "config", "=", "self", "::", "getInstance", "(", "$", "name", ")", ";", "$", "key", "=", "self", "::", "_instanceKey", "(", "$", "name", ")", ";", "$", "result", "=", "$", "adapter", "->", "save", "(", "$", "key", ",", "$", "config", ")", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "return", "$", "result", ";", "}" ]
Save config instance data @param string $name Config name @return boolean
[ "Save", "config", "instance", "data" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L131-L144
train
covex-nn/JooS
src/JooS/Config/Config.php
Config.deleteInstance
public static function deleteInstance($name) { $adapter = self::getDataAdapter(); if (!is_null($adapter)) { $key = self::_instanceKey($name); $result = $adapter->delete($key); } else { $result = false; } self::clearInstance($name); return $result; }
php
public static function deleteInstance($name) { $adapter = self::getDataAdapter(); if (!is_null($adapter)) { $key = self::_instanceKey($name); $result = $adapter->delete($key); } else { $result = false; } self::clearInstance($name); return $result; }
[ "public", "static", "function", "deleteInstance", "(", "$", "name", ")", "{", "$", "adapter", "=", "self", "::", "getDataAdapter", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "adapter", ")", ")", "{", "$", "key", "=", "self", "::", "_instanceKey", "(", "$", "name", ")", ";", "$", "result", "=", "$", "adapter", "->", "delete", "(", "$", "key", ")", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "self", "::", "clearInstance", "(", "$", "name", ")", ";", "return", "$", "result", ";", "}" ]
Delete config instance data @param string $name Config name @return boolean
[ "Delete", "config", "instance", "data" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Config.php#L153-L166
train
freialib/freia.autoloader
src/Configs.php
Configs.instance
static function instance(\hlin\archetype\Filesystem $fs, array $filemaps) { $i = new static; $i->fs = $fs; $i->filemaps = $filemaps; return $i; }
php
static function instance(\hlin\archetype\Filesystem $fs, array $filemaps) { $i = new static; $i->fs = $fs; $i->filemaps = $filemaps; return $i; }
[ "static", "function", "instance", "(", "\\", "hlin", "\\", "archetype", "\\", "Filesystem", "$", "fs", ",", "array", "$", "filemaps", ")", "{", "$", "i", "=", "new", "static", ";", "$", "i", "->", "fs", "=", "$", "fs", ";", "$", "i", "->", "filemaps", "=", "$", "filemaps", ";", "return", "$", "i", ";", "}" ]
Default filemaps will be used if none are specified. @return static
[ "Default", "filemaps", "will", "be", "used", "if", "none", "are", "specified", "." ]
45e0dfcd56d55cf533f12255db647e8a05fcd494
https://github.com/freialib/freia.autoloader/blob/45e0dfcd56d55cf533f12255db647e8a05fcd494/src/Configs.php#L25-L30
train
PascalKleindienst/simple-api-client
src/Client.php
Client.get
public function get($endpoint, $params = []) { // build url $url = $this->domain . '/' . $endpoint; if (!empty($params)) { $url = $url . '?' . http_build_query($params); } $request = new Request($url); // Add client secret header if (isset($this->config['secret'])) { $request->headers->add(['X-Client-Secret' => $this->config['secret']]); } // add curl options if (isset($this->config['curl']) && is_array($this->config['curl'])) { foreach ($this->config['curl'] as $option => $value) { $request->setOption($option, $value); } } $request->execute(); return $request->getResponse(); }
php
public function get($endpoint, $params = []) { // build url $url = $this->domain . '/' . $endpoint; if (!empty($params)) { $url = $url . '?' . http_build_query($params); } $request = new Request($url); // Add client secret header if (isset($this->config['secret'])) { $request->headers->add(['X-Client-Secret' => $this->config['secret']]); } // add curl options if (isset($this->config['curl']) && is_array($this->config['curl'])) { foreach ($this->config['curl'] as $option => $value) { $request->setOption($option, $value); } } $request->execute(); return $request->getResponse(); }
[ "public", "function", "get", "(", "$", "endpoint", ",", "$", "params", "=", "[", "]", ")", "{", "// build url", "$", "url", "=", "$", "this", "->", "domain", ".", "'/'", ".", "$", "endpoint", ";", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "$", "url", "=", "$", "url", ".", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "$", "request", "=", "new", "Request", "(", "$", "url", ")", ";", "// Add client secret header", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'secret'", "]", ")", ")", "{", "$", "request", "->", "headers", "->", "add", "(", "[", "'X-Client-Secret'", "=>", "$", "this", "->", "config", "[", "'secret'", "]", "]", ")", ";", "}", "// add curl options", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'curl'", "]", ")", "&&", "is_array", "(", "$", "this", "->", "config", "[", "'curl'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "config", "[", "'curl'", "]", "as", "$", "option", "=>", "$", "value", ")", "{", "$", "request", "->", "setOption", "(", "$", "option", ",", "$", "value", ")", ";", "}", "}", "$", "request", "->", "execute", "(", ")", ";", "return", "$", "request", "->", "getResponse", "(", ")", ";", "}" ]
Make a GET Request to an endpoint @param $endpoint @param array $params @return \Jyggen\Curl\Response @throws \Jyggen\Curl\Exception\CurlErrorException @throws \Jyggen\Curl\Exception\ProtectedOptionException
[ "Make", "a", "GET", "Request", "to", "an", "endpoint" ]
f4e20aa65bb9c340b8aff78acaede7dc62cd2105
https://github.com/PascalKleindienst/simple-api-client/blob/f4e20aa65bb9c340b8aff78acaede7dc62cd2105/src/Client.php#L84-L110
train
PascalKleindienst/simple-api-client
src/Client.php
Client.getEndpoint
public function getEndpoint($endpoint) { // Get Endpoint Class name $endpoint = studly_case($endpoint); if (!array_key_exists($endpoint, $this->endpoints)) { throw new InvalidEndpointException("Endpoint {$endpoint} does not exists"); } $class = $this->endpoints[$endpoint]; // Check if an instance has already been initiated if (isset($this->cachedEndpoints[$endpoint]) === false) { // check if class is an EndPoint $endpointClass = new \ReflectionClass($class); if (!$endpointClass->isSubclassOf('Atog\Api\Endpoint')) { throw new InvalidEndpointException("Class {$class} does not extend Atog\\Api\\Endpoint"); } // check for model $model = new Model(); if (array_key_exists('models', $this->config) && array_key_exists($endpoint, $this->config['models'])) { $modelClass = $this->config['models'][$endpoint]; if (class_exists($modelClass)) { $model = new $modelClass(); } } $this->cachedEndpoints[$endpoint] = new $class($this, $model); } return $this->cachedEndpoints[$endpoint]; }
php
public function getEndpoint($endpoint) { // Get Endpoint Class name $endpoint = studly_case($endpoint); if (!array_key_exists($endpoint, $this->endpoints)) { throw new InvalidEndpointException("Endpoint {$endpoint} does not exists"); } $class = $this->endpoints[$endpoint]; // Check if an instance has already been initiated if (isset($this->cachedEndpoints[$endpoint]) === false) { // check if class is an EndPoint $endpointClass = new \ReflectionClass($class); if (!$endpointClass->isSubclassOf('Atog\Api\Endpoint')) { throw new InvalidEndpointException("Class {$class} does not extend Atog\\Api\\Endpoint"); } // check for model $model = new Model(); if (array_key_exists('models', $this->config) && array_key_exists($endpoint, $this->config['models'])) { $modelClass = $this->config['models'][$endpoint]; if (class_exists($modelClass)) { $model = new $modelClass(); } } $this->cachedEndpoints[$endpoint] = new $class($this, $model); } return $this->cachedEndpoints[$endpoint]; }
[ "public", "function", "getEndpoint", "(", "$", "endpoint", ")", "{", "// Get Endpoint Class name", "$", "endpoint", "=", "studly_case", "(", "$", "endpoint", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "endpoint", ",", "$", "this", "->", "endpoints", ")", ")", "{", "throw", "new", "InvalidEndpointException", "(", "\"Endpoint {$endpoint} does not exists\"", ")", ";", "}", "$", "class", "=", "$", "this", "->", "endpoints", "[", "$", "endpoint", "]", ";", "// Check if an instance has already been initiated", "if", "(", "isset", "(", "$", "this", "->", "cachedEndpoints", "[", "$", "endpoint", "]", ")", "===", "false", ")", "{", "// check if class is an EndPoint", "$", "endpointClass", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "!", "$", "endpointClass", "->", "isSubclassOf", "(", "'Atog\\Api\\Endpoint'", ")", ")", "{", "throw", "new", "InvalidEndpointException", "(", "\"Class {$class} does not extend Atog\\\\Api\\\\Endpoint\"", ")", ";", "}", "// check for model", "$", "model", "=", "new", "Model", "(", ")", ";", "if", "(", "array_key_exists", "(", "'models'", ",", "$", "this", "->", "config", ")", "&&", "array_key_exists", "(", "$", "endpoint", ",", "$", "this", "->", "config", "[", "'models'", "]", ")", ")", "{", "$", "modelClass", "=", "$", "this", "->", "config", "[", "'models'", "]", "[", "$", "endpoint", "]", ";", "if", "(", "class_exists", "(", "$", "modelClass", ")", ")", "{", "$", "model", "=", "new", "$", "modelClass", "(", ")", ";", "}", "}", "$", "this", "->", "cachedEndpoints", "[", "$", "endpoint", "]", "=", "new", "$", "class", "(", "$", "this", ",", "$", "model", ")", ";", "}", "return", "$", "this", "->", "cachedEndpoints", "[", "$", "endpoint", "]", ";", "}" ]
Get an API endpoint. @param string $endpoint @return \Atog\Api\Endpoint @throws \Atog\Api\Exceptions\InvalidEndpointException
[ "Get", "an", "API", "endpoint", "." ]
f4e20aa65bb9c340b8aff78acaede7dc62cd2105
https://github.com/PascalKleindienst/simple-api-client/blob/f4e20aa65bb9c340b8aff78acaede7dc62cd2105/src/Client.php#L129-L160
train
ARCANESOFT/Blog
src/Blog.php
Blog.routes
public static function routes() { Route::name('public::blog.') ->prefix('blog') ->namespace('\\Arcanesoft\\Blog\\Http\\Controllers\\Front') ->group(function () { Routes\PostsRoutes::register(); Routes\CategoriesRoutes::register(); Routes\TagsRoutes::register(); }); }
php
public static function routes() { Route::name('public::blog.') ->prefix('blog') ->namespace('\\Arcanesoft\\Blog\\Http\\Controllers\\Front') ->group(function () { Routes\PostsRoutes::register(); Routes\CategoriesRoutes::register(); Routes\TagsRoutes::register(); }); }
[ "public", "static", "function", "routes", "(", ")", "{", "Route", "::", "name", "(", "'public::blog.'", ")", "->", "prefix", "(", "'blog'", ")", "->", "namespace", "(", "'\\\\Arcanesoft\\\\Blog\\\\Http\\\\Controllers\\\\Front'", ")", "->", "group", "(", "function", "(", ")", "{", "Routes", "\\", "PostsRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "CategoriesRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "TagsRoutes", "::", "register", "(", ")", ";", "}", ")", ";", "}" ]
Register the public blog routes.
[ "Register", "the", "public", "blog", "routes", "." ]
2078fdfdcbccda161c02899b9e1f344f011b2859
https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Blog.php#L58-L68
train
dsv-su/daisy-api-client-php
src/Publication.php
Publication.find
public static function find(array $query) { $pubs = Client::get('publication', $query); return array_map(function ($data) { return new self($data); }, $pubs); }
php
public static function find(array $query) { $pubs = Client::get('publication', $query); return array_map(function ($data) { return new self($data); }, $pubs); }
[ "public", "static", "function", "find", "(", "array", "$", "query", ")", "{", "$", "pubs", "=", "Client", "::", "get", "(", "'publication'", ",", "$", "query", ")", ";", "return", "array_map", "(", "function", "(", "$", "data", ")", "{", "return", "new", "self", "(", "$", "data", ")", ";", "}", ",", "$", "pubs", ")", ";", "}" ]
Retrieve an array of Publication objects according to a search query. @param array $query The query. @return Publication[]
[ "Retrieve", "an", "array", "of", "Publication", "objects", "according", "to", "a", "search", "query", "." ]
aa6817ed45fdf3629c9683ea8a8e70a80f59b441
https://github.com/dsv-su/daisy-api-client-php/blob/aa6817ed45fdf3629c9683ea8a8e70a80f59b441/src/Publication.php#L15-L19
train
rutger-speksnijder/restphp
src/RestPHP/Response/Types/HTML.php
HTML.transformToHtml
private function transformToHtml($data, $hypertextRoutes = []) { // Generate the html for the hypertext routes $hypertextHtml = $this->getHypertextHtml($hypertextRoutes); // Check if the data is not an array if (!is_array($data)) { return "<p>{$data}</p>\n{$hypertextHtml}"; } // Generate the html table $html = "<table style=\"border: 1px solid black;\">"; foreach ($data as $k => $v) { if (is_array($v)) { // Recursively transform underlying data $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">{$k}:</td><td style=\"border: 1px solid black;\">{$this->transformToHtml($v)}</td></tr>"; } else { $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">{$k}:</td><td style=\"border: 1px solid black;\">{$v}</td></tr>"; } } // Add the hypertext html $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">Hypertext:</td><td style=\"border: 1px solid black;\">{$hypertextHtml}</td></tr>"; $html .= "</table>"; return $html; }
php
private function transformToHtml($data, $hypertextRoutes = []) { // Generate the html for the hypertext routes $hypertextHtml = $this->getHypertextHtml($hypertextRoutes); // Check if the data is not an array if (!is_array($data)) { return "<p>{$data}</p>\n{$hypertextHtml}"; } // Generate the html table $html = "<table style=\"border: 1px solid black;\">"; foreach ($data as $k => $v) { if (is_array($v)) { // Recursively transform underlying data $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">{$k}:</td><td style=\"border: 1px solid black;\">{$this->transformToHtml($v)}</td></tr>"; } else { $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">{$k}:</td><td style=\"border: 1px solid black;\">{$v}</td></tr>"; } } // Add the hypertext html $html .= "<tr><td style=\"border: 1px solid black; font-weight: bold;\">Hypertext:</td><td style=\"border: 1px solid black;\">{$hypertextHtml}</td></tr>"; $html .= "</table>"; return $html; }
[ "private", "function", "transformToHtml", "(", "$", "data", ",", "$", "hypertextRoutes", "=", "[", "]", ")", "{", "// Generate the html for the hypertext routes", "$", "hypertextHtml", "=", "$", "this", "->", "getHypertextHtml", "(", "$", "hypertextRoutes", ")", ";", "// Check if the data is not an array", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "\"<p>{$data}</p>\\n{$hypertextHtml}\"", ";", "}", "// Generate the html table", "$", "html", "=", "\"<table style=\\\"border: 1px solid black;\\\">\"", ";", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "// Recursively transform underlying data", "$", "html", ".=", "\"<tr><td style=\\\"border: 1px solid black; font-weight: bold;\\\">{$k}:</td><td style=\\\"border: 1px solid black;\\\">{$this->transformToHtml($v)}</td></tr>\"", ";", "}", "else", "{", "$", "html", ".=", "\"<tr><td style=\\\"border: 1px solid black; font-weight: bold;\\\">{$k}:</td><td style=\\\"border: 1px solid black;\\\">{$v}</td></tr>\"", ";", "}", "}", "// Add the hypertext html", "$", "html", ".=", "\"<tr><td style=\\\"border: 1px solid black; font-weight: bold;\\\">Hypertext:</td><td style=\\\"border: 1px solid black;\\\">{$hypertextHtml}</td></tr>\"", ";", "$", "html", ".=", "\"</table>\"", ";", "return", "$", "html", ";", "}" ]
Recursively converts the response into an html string. This is an html string with tables and underlying tables. @param mixed $data The data to transform. @param optional array $hypertextRoutes An array with hypertext routes. @return string The response as an html string.
[ "Recursively", "converts", "the", "response", "into", "an", "html", "string", ".", "This", "is", "an", "html", "string", "with", "tables", "and", "underlying", "tables", "." ]
326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/HTML.php#L49-L74
train
rutger-speksnijder/restphp
src/RestPHP/Response/Types/HTML.php
HTML.getHypertextHtml
private function getHypertextHtml($routes = []) { // Check if we have routes if (!$routes) { return ''; } // Create the html table $html = "<table style=\"border: 1px solid black;\">\n"; // Loop through the routes and add them as rows to the table foreach ($routes as $name => $route) { $html .= "<tr>\n"; $html .= "<td style=\"border: 1px solid black;\">rel: {$name}</td>\n"; $html .= "<td style=\"border: 1px solid black;\">href: {$route}</td>\n"; $html .= "</tr>\n"; } $html .= "</table>\n"; return $html; }
php
private function getHypertextHtml($routes = []) { // Check if we have routes if (!$routes) { return ''; } // Create the html table $html = "<table style=\"border: 1px solid black;\">\n"; // Loop through the routes and add them as rows to the table foreach ($routes as $name => $route) { $html .= "<tr>\n"; $html .= "<td style=\"border: 1px solid black;\">rel: {$name}</td>\n"; $html .= "<td style=\"border: 1px solid black;\">href: {$route}</td>\n"; $html .= "</tr>\n"; } $html .= "</table>\n"; return $html; }
[ "private", "function", "getHypertextHtml", "(", "$", "routes", "=", "[", "]", ")", "{", "// Check if we have routes", "if", "(", "!", "$", "routes", ")", "{", "return", "''", ";", "}", "// Create the html table", "$", "html", "=", "\"<table style=\\\"border: 1px solid black;\\\">\\n\"", ";", "// Loop through the routes and add them as rows to the table", "foreach", "(", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "$", "html", ".=", "\"<tr>\\n\"", ";", "$", "html", ".=", "\"<td style=\\\"border: 1px solid black;\\\">rel: {$name}</td>\\n\"", ";", "$", "html", ".=", "\"<td style=\\\"border: 1px solid black;\\\">href: {$route}</td>\\n\"", ";", "$", "html", ".=", "\"</tr>\\n\"", ";", "}", "$", "html", ".=", "\"</table>\\n\"", ";", "return", "$", "html", ";", "}" ]
Generates the html for the hypertext routes. @param optional array $routes The hypertext routes. @return string The hypertext routes html table.
[ "Generates", "the", "html", "for", "the", "hypertext", "routes", "." ]
326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/HTML.php#L83-L103
train
timostamm/web-resource
src/FileResource.php
FileResource.fromResource
public static function fromResource(ResourceInterface $resource, $path) { if ($resource instanceof FileResourceInterface) { return $resource; } file_put_contents($path, $resource->getStream()); $attr = [ 'mimetype' => $resource->getMimetype(), 'lastmodified' => $resource->getLastModified(), 'filename' => $resource->getFilename() ]; return new FileResource($path, $attr); }
php
public static function fromResource(ResourceInterface $resource, $path) { if ($resource instanceof FileResourceInterface) { return $resource; } file_put_contents($path, $resource->getStream()); $attr = [ 'mimetype' => $resource->getMimetype(), 'lastmodified' => $resource->getLastModified(), 'filename' => $resource->getFilename() ]; return new FileResource($path, $attr); }
[ "public", "static", "function", "fromResource", "(", "ResourceInterface", "$", "resource", ",", "$", "path", ")", "{", "if", "(", "$", "resource", "instanceof", "FileResourceInterface", ")", "{", "return", "$", "resource", ";", "}", "file_put_contents", "(", "$", "path", ",", "$", "resource", "->", "getStream", "(", ")", ")", ";", "$", "attr", "=", "[", "'mimetype'", "=>", "$", "resource", "->", "getMimetype", "(", ")", ",", "'lastmodified'", "=>", "$", "resource", "->", "getLastModified", "(", ")", ",", "'filename'", "=>", "$", "resource", "->", "getFilename", "(", ")", "]", ";", "return", "new", "FileResource", "(", "$", "path", ",", "$", "attr", ")", ";", "}" ]
Converts any resource to a local resource. @param ResourceInterface $resource @param string $path @return FileResource
[ "Converts", "any", "resource", "to", "a", "local", "resource", "." ]
4c60e679093990585ee2f0a00029ab0a218573b8
https://github.com/timostamm/web-resource/blob/4c60e679093990585ee2f0a00029ab0a218573b8/src/FileResource.php#L26-L38
train
agentmedia/phine-core
src/Core/Logic/Access/Backend/RightsFinder.php
RightsFinder.FindContentRights
static function FindContentRights(Content $content) { $result = null; $currContent = $content; do { $result = $currContent->GetUserGroupRights(); $currContent = ContentTreeUtil::ParentOf($currContent); } while (!$result && $currContent); if ($result) { return $result; } return self::GetUpperContentRights($content); }
php
static function FindContentRights(Content $content) { $result = null; $currContent = $content; do { $result = $currContent->GetUserGroupRights(); $currContent = ContentTreeUtil::ParentOf($currContent); } while (!$result && $currContent); if ($result) { return $result; } return self::GetUpperContentRights($content); }
[ "static", "function", "FindContentRights", "(", "Content", "$", "content", ")", "{", "$", "result", "=", "null", ";", "$", "currContent", "=", "$", "content", ";", "do", "{", "$", "result", "=", "$", "currContent", "->", "GetUserGroupRights", "(", ")", ";", "$", "currContent", "=", "ContentTreeUtil", "::", "ParentOf", "(", "$", "currContent", ")", ";", "}", "while", "(", "!", "$", "result", "&&", "$", "currContent", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "result", ";", "}", "return", "self", "::", "GetUpperContentRights", "(", "$", "content", ")", ";", "}" ]
Finds the content rigths by searching in element tree @param Content $content The content @return BackendContentRights The rights of the contents
[ "Finds", "the", "content", "rigths", "by", "searching", "in", "element", "tree" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Access/Backend/RightsFinder.php#L17-L32
train
agentmedia/phine-core
src/Core/Logic/Access/Backend/RightsFinder.php
RightsFinder.FindPageRights
static function FindPageRights(Page $page) { $currPage = $page; $result = null; do { $result = $currPage->GetUserGroupRights(); $currPage = $currPage->GetParent(); } while (!$result && $currPage); if (!$result && $page->GetSite()) { $siteRights = $page->GetSite()->GetUserGroupRights(); if ($siteRights) { return $siteRights->GetPageRights(); } } return $result; }
php
static function FindPageRights(Page $page) { $currPage = $page; $result = null; do { $result = $currPage->GetUserGroupRights(); $currPage = $currPage->GetParent(); } while (!$result && $currPage); if (!$result && $page->GetSite()) { $siteRights = $page->GetSite()->GetUserGroupRights(); if ($siteRights) { return $siteRights->GetPageRights(); } } return $result; }
[ "static", "function", "FindPageRights", "(", "Page", "$", "page", ")", "{", "$", "currPage", "=", "$", "page", ";", "$", "result", "=", "null", ";", "do", "{", "$", "result", "=", "$", "currPage", "->", "GetUserGroupRights", "(", ")", ";", "$", "currPage", "=", "$", "currPage", "->", "GetParent", "(", ")", ";", "}", "while", "(", "!", "$", "result", "&&", "$", "currPage", ")", ";", "if", "(", "!", "$", "result", "&&", "$", "page", "->", "GetSite", "(", ")", ")", "{", "$", "siteRights", "=", "$", "page", "->", "GetSite", "(", ")", "->", "GetUserGroupRights", "(", ")", ";", "if", "(", "$", "siteRights", ")", "{", "return", "$", "siteRights", "->", "GetPageRights", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Gets the rights of the page @param Page $page @return BackendPageRights
[ "Gets", "the", "rights", "of", "the", "page" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Access/Backend/RightsFinder.php#L85-L104
train
Kris-Kuiper/sFire-Framework
src/Hash/HashTrait.php
HashTrait.hash
public static function hash($data) { if(false === is_string($data) && false === is_numeric($data)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR); } return hash(self :: HASH_ALGORITHM, $data); }
php
public static function hash($data) { if(false === is_string($data) && false === is_numeric($data)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR); } return hash(self :: HASH_ALGORITHM, $data); }
[ "public", "static", "function", "hash", "(", "$", "data", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "data", ")", "&&", "false", "===", "is_numeric", "(", "$", "data", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string or number, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "data", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "return", "hash", "(", "self", "::", "HASH_ALGORITHM", ",", "$", "data", ")", ";", "}" ]
Hashes text and returns it @param string $data @return string
[ "Hashes", "text", "and", "returns", "it" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Hash/HashTrait.php#L67-L74
train
Kris-Kuiper/sFire-Framework
src/Hash/HashTrait.php
HashTrait.validateHash
public static function validateHash($data, $hash) { if(false === is_string($data) && false === is_numeric($data)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR); } if(false === is_string($hash)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($hash)), E_USER_ERROR); } return hash(self :: HASH_ALGORITHM, $data) === $hash; }
php
public static function validateHash($data, $hash) { if(false === is_string($data) && false === is_numeric($data)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR); } if(false === is_string($hash)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($hash)), E_USER_ERROR); } return hash(self :: HASH_ALGORITHM, $data) === $hash; }
[ "public", "static", "function", "validateHash", "(", "$", "data", ",", "$", "hash", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "data", ")", "&&", "false", "===", "is_numeric", "(", "$", "data", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string or number, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "data", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "===", "is_string", "(", "$", "hash", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "hash", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "return", "hash", "(", "self", "::", "HASH_ALGORITHM", ",", "$", "data", ")", "===", "$", "hash", ";", "}" ]
Verifies that data matches a hash @param string $data @param string $hash @return boolean
[ "Verifies", "that", "data", "matches", "a", "hash" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Hash/HashTrait.php#L83-L94
train
Kris-Kuiper/sFire-Framework
src/Hash/HashTrait.php
HashTrait.hash_equals
private static function hash_equals($expected, $actual) { $expected = (string) $expected; $actual = (string) $actual; if(true === function_exists('hash_equals')) { return hash_equals($expected, $actual); } $lenExpected = mb_strlen($expected, self :: ENCODING); $lenActual = mb_strlen($actual, self :: ENCODING); $len = min($lenExpected, $lenActual); $result = 0; for ($i = 0; $i < $len; $i++) { $result |= ord($expected[$i]) ^ ord($actual[$i]); } $result |= $lenExpected ^ $lenActual; return ($result === 0); }
php
private static function hash_equals($expected, $actual) { $expected = (string) $expected; $actual = (string) $actual; if(true === function_exists('hash_equals')) { return hash_equals($expected, $actual); } $lenExpected = mb_strlen($expected, self :: ENCODING); $lenActual = mb_strlen($actual, self :: ENCODING); $len = min($lenExpected, $lenActual); $result = 0; for ($i = 0; $i < $len; $i++) { $result |= ord($expected[$i]) ^ ord($actual[$i]); } $result |= $lenExpected ^ $lenActual; return ($result === 0); }
[ "private", "static", "function", "hash_equals", "(", "$", "expected", ",", "$", "actual", ")", "{", "$", "expected", "=", "(", "string", ")", "$", "expected", ";", "$", "actual", "=", "(", "string", ")", "$", "actual", ";", "if", "(", "true", "===", "function_exists", "(", "'hash_equals'", ")", ")", "{", "return", "hash_equals", "(", "$", "expected", ",", "$", "actual", ")", ";", "}", "$", "lenExpected", "=", "mb_strlen", "(", "$", "expected", ",", "self", "::", "ENCODING", ")", ";", "$", "lenActual", "=", "mb_strlen", "(", "$", "actual", ",", "self", "::", "ENCODING", ")", ";", "$", "len", "=", "min", "(", "$", "lenExpected", ",", "$", "lenActual", ")", ";", "$", "result", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "result", "|=", "ord", "(", "$", "expected", "[", "$", "i", "]", ")", "^", "ord", "(", "$", "actual", "[", "$", "i", "]", ")", ";", "}", "$", "result", "|=", "$", "lenExpected", "^", "$", "lenActual", ";", "return", "(", "$", "result", "===", "0", ")", ";", "}" ]
Hash equals function for PHP 5.5+ @param string $expected @param string $actual @return bool
[ "Hash", "equals", "function", "for", "PHP", "5", ".", "5", "+" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Hash/HashTrait.php#L103-L124
train
duncan3dc/serial
src/Yaml.php
Yaml.decode
public static function decode($string) { if (!$string) { return new ArrayObject(); } $array = SymfonyYaml::parse($string); if (!is_array($array)) { $array = []; } return ArrayObject::make($array); }
php
public static function decode($string) { if (!$string) { return new ArrayObject(); } $array = SymfonyYaml::parse($string); if (!is_array($array)) { $array = []; } return ArrayObject::make($array); }
[ "public", "static", "function", "decode", "(", "$", "string", ")", "{", "if", "(", "!", "$", "string", ")", "{", "return", "new", "ArrayObject", "(", ")", ";", "}", "$", "array", "=", "SymfonyYaml", "::", "parse", "(", "$", "string", ")", ";", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "$", "array", "=", "[", "]", ";", "}", "return", "ArrayObject", "::", "make", "(", "$", "array", ")", ";", "}" ]
Convert a yaml string to an array. {@inheritDoc}
[ "Convert", "a", "yaml", "string", "to", "an", "array", "." ]
2e40127a0a364ee1bd6f655b0f5b5d4a035a5716
https://github.com/duncan3dc/serial/blob/2e40127a0a364ee1bd6f655b0f5b5d4a035a5716/src/Yaml.php#L33-L46
train
pdyn/filesystem
Mimetype.php
Mimetype.mime2ext
public static function mime2ext($mime) { $ext2mime = static::get_mime_map(); $mime2ext = array_flip($ext2mime); return (isset($mime2ext[$mime])) ? $mime2ext[$mime] : 'unknown'; }
php
public static function mime2ext($mime) { $ext2mime = static::get_mime_map(); $mime2ext = array_flip($ext2mime); return (isset($mime2ext[$mime])) ? $mime2ext[$mime] : 'unknown'; }
[ "public", "static", "function", "mime2ext", "(", "$", "mime", ")", "{", "$", "ext2mime", "=", "static", "::", "get_mime_map", "(", ")", ";", "$", "mime2ext", "=", "array_flip", "(", "$", "ext2mime", ")", ";", "return", "(", "isset", "(", "$", "mime2ext", "[", "$", "mime", "]", ")", ")", "?", "$", "mime2ext", "[", "$", "mime", "]", ":", "'unknown'", ";", "}" ]
Get the file extension associated with a given mime type. @param string $mime The mime type. @return string The file extension.
[ "Get", "the", "file", "extension", "associated", "with", "a", "given", "mime", "type", "." ]
e2f780eac166aa60071e601d600133b860ace594
https://github.com/pdyn/filesystem/blob/e2f780eac166aa60071e601d600133b860ace594/Mimetype.php#L29-L33
train