Ejemplo n.º 1
0
 /**
  * @param string $pattern
  * @param string $word
  * @return int position from left where the pattern matched from right otherwise -1
  */
 protected function match($pattern, $word)
 {
     if (substr($pattern, 0, 1) !== '-') {
         return strcasecmp($pattern, $word) === 0 ? 0 : -1;
     }
     $matches = [];
     if (preg_match('/' . substr($pattern, 1) . '$/iu', $word, $matches)) {
         var_dumP($pattern);
         for ($i = count($matches) - 1; $i > 0; $i--) {
             $this->replacements[$i - 1] = $matches[count($matches) - $i];
         }
         return mb_strlen($word, 'UTF-8') - mb_strlen($matches[0], 'UTF-8');
     }
     return -1;
 }
Ejemplo n.º 2
0
<?php

$loader = (require __DIR__ . '/vendor/autoload.php');
$lib = new Inflection();
array_shift($argv);
foreach ($argv as $word) {
    var_dumP($lib->inflect($word));
}
Ejemplo n.º 3
0
 public static function processList(DOMElement $element, $flags = 0, $level = 0)
 {
     // TODO handle indented lists
     $tagName = strtoupper($element->tagName);
     if (!in_array($tagName, array('OL', 'UL', 'DL'))) {
         throw new InvalidArgumentException('Not a list: ' . $tagName);
     }
     // Lists in LaTeX can be 4 levels deep
     if ($level >= 4) {
         return self::getText($element, self::NO_PARAGRAPH | self::TRIM);
     }
     $env = null;
     if ($tagName === 'OL') {
         $env = 'enumerate';
     } elseif ($tagName === 'UL') {
         $env = 'itemize';
     } elseif ($tagName === 'DL') {
         $env = 'description';
     }
     $latex = '';
     // paragraphs in list item?
     $prevTag = null;
     foreach ($element->childNodes as $item) {
         if ($item->nodeType !== XML_ELEMENT_NODE) {
             continue;
         }
         $t = strtoupper($item->tagName);
         switch ($t) {
             case 'LI':
             case 'DD':
                 $text = self::processBlock($item, self::TRIM | self::NO_HEADINGS);
                 // there can be more than one paragraph in list item
                 $text = preg_replace('/\\n[ \\t]*\\n+/', "\n\n", trim($text));
                 if ($t == 'LI' || $t == 'DD' && (!$prevTag && $prevTag !== 'DT')) {
                     $latex .= '    \\item ' . trim($text) . "\n";
                 } else {
                     $latex .= '    ' . trim($text) . "\n";
                 }
                 break;
             case 'DT':
                 $text = self::getText($item, self::TRIM | self::NO_PARAGRAPH);
                 $latex .= '    \\item';
                 if (strlen($text)) {
                     $latex .= '[{' . $text . '}]' . "\n";
                 }
                 break;
             default:
                 var_dumP($item);
                 exit;
         }
         $prevTag = $t;
     }
     return sprintf("\\begin{%s}\n%s\\end{%s}\n\n", $env, $latex, $env);
 }
Ejemplo n.º 4
0
 /**
  * Rompe enlace entre un permiso y un rol
  *
  * @param  int  $id
  * @return Response
  */
 public function permissions($id)
 {
     $data["id"] = $id;
     $validator = Validator::make($data, ['id' => 'integer']);
     if ($validator->fails()) {
         return response()->json(["msg" => "alert", "validator" => $validator->messages()], 200);
     }
     if ($role = Role::find($id)) {
         $permission_role = Permission_role::leftjoin('permissions', 'permission_role.permission_id', '=', 'permissions.id')->where('role_id', $id)->get();
         var_dumP($permission_role);
         if (!empty($permission_role)) {
             return response()->json(["msg" => "Success", "users" => $permission_role], 200);
         } else {
             $description = "Rol vacio";
         }
     } else {
         $description = "No se ha encontrado el rol";
     }
     return response()->json(["msg" => "error", "description" => $description], 200);
 }