示例#1
0
 public function getData($key = null)
 {
     if (null !== $key) {
         return Arrays::get($this->data, $key);
     }
     return $this->data;
 }
示例#2
0
文件: Dns.php 项目: domraider/rxnet
 public function convert($type)
 {
     $type = strtoupper($type);
     $types = ["A" => 1, "AAAA" => 28, "AFSDB" => 18, "CAA" => 257, "CERT" => 37, "CNAME" => 5, "DHCID" => 49, "DLV" => 32769, "DNAME" => 39, "DNSKEY" => 48, "DS" => 43, "HINFO" => 13, "KEY" => 25, "KX" => 36, "ISDN" => 20, "LOC" => 29, "MB" => 7, "MD" => 3, "MF" => 4, "MG" => 8, "MINFO" => 14, "MR" => 9, "MX" => 15, "NAPTR" => 35, "NS" => 2, "NULL" => 10, "PTR" => 12, "RP" => 17, "RT" => 21, "SIG" => 24, "SOA" => 6, "SPF" => 99, "SRV" => 33, "TXT" => 16, "WKS" => 11, "X25" => 19];
     if (!($code = Arrays::get($types, $type))) {
         throw new \InvalidArgumentException("No DNS type exists for {$type}");
     }
     return $code;
 }
示例#3
0
 public function __construct($message, $labels = [], \Exception $previous = null)
 {
     $this->labels = $labels;
     if (!is_array($labels)) {
         var_dump($labels);
         die;
     }
     $code = Arrays::get($labels, 'code', 500);
     if ($previous) {
         $message .= ' > ' . $previous->getMessage();
     }
     parent::__construct($message, $code, $previous);
 }
示例#4
0
 /**
  * Querry database using appropriate filters
  *
  * @var string
  */
 public function filter(array $filters)
 {
     $query = $this->model;
     // 'from' filter : lower limit for dates in the query
     $fromFilter = Arrays::get($filters, 'from');
     if ($fromFilter) {
         $query = $query->where('date', '>=', $fromFilter);
     }
     // 'to' filter : upper limit for dates in the query
     $toFilter = Arrays::get($filters, 'to');
     if ($toFilter) {
         $query = $query->where('date', '<=', $toFilter);
     }
     // 'author' filter : adds author property to where clause
     $authorFilter = Arrays::get($filters, 'author');
     if ($authorFilter) {
         $query = $query->where('author', '=', $authorFilter);
     }
     return $query->orderBy('date', 'desc')->get();
 }
示例#5
0
 public function testCanFallbackClosure()
 {
     $array = array('foo' => array('bar' => 'bis'));
     $under = Arrays::get($array, 'ter', function () {
         return 'closure';
     });
     $this->assertEquals('closure', $under);
 }
示例#6
0
文件: Http.php 项目: domraider/rxnet
 /**
  * @param $scheme
  * @param array $opts
  * @return Tcp|Tls
  */
 public function getConnector($scheme, array $opts = [])
 {
     if ($scheme == 'http') {
         return new Tcp($this->loop);
     }
     $connector = new Tls($this->loop);
     if ($sslOpts = Arrays::get($opts, 'ssl')) {
         $connector->setSslContextParams($sslOpts);
     }
     return $connector;
 }
示例#7
0
 /**
  * Resolve values by collection.
  *
  * @param  \SimpleXMLElement  $content
  * @param  array  $matches
  * @param  mixed  $default
  *
  * @return array
  */
 protected function getValueCollection(SimpleXMLElement $content, array $matches, $default = null)
 {
     $parent = $matches[1];
     $namespace = null;
     if (strpos($parent, '/') !== false) {
         list($parent, $namespace) = explode('/', $parent, 2);
     }
     $collection = Arrays::get($content, $parent);
     $namespaces = $this->getAvailableNamespaces();
     $uses = explode(',', $matches[2]);
     $values = [];
     if (!$collection instanceof SimpleXMLElement) {
         return $default;
     }
     foreach ($collection as $content) {
         if (empty($content)) {
             continue;
         }
         if (!is_null($namespace) && isset($namespaces[$namespace])) {
             $content = $content->children($namespaces[$namespace]);
         }
         $values[] = $this->parseValueCollection($content, $uses);
     }
     return $values;
 }