Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • Hooks
  • ManageBlock
  • Model
  • Module
  • SaveOperation
  • ServerName
  • Site
  • StatusOperation
 1 <?php
 2 
 3 /*
 4  * This file is part of the Icybee package.
 5  *
 6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
 7  *
 8  * For the full copyright and license information, please view the LICENSE
 9  * file that was distributed with this source code.
10  */
11 
12 namespace Icybee\Modules\Sites;
13 
14 /**
15  * A representation of a server name.
16  */
17 class ServerName
18 {
19     public $subdomain;
20     public $domain;
21     public $tld;
22 
23     public function __construct($server_name)
24     {
25         $this->modify($server_name);
26     }
27 
28     /**
29      * Returns a string representation of the server name.
30      *
31      * @return string
32      */
33     public function __toString()
34     {
35         $parts = array($this->subdomain, $this->domain, $this->tld);
36         $parts = array_filter($parts);
37 
38         return implode('.', $parts);
39     }
40 
41     /**
42      * Modifies the server name.
43      *
44      * The method updates the {@link $subdomain}, {@link $domain} and {@link $tld} properties.
45      *
46      * @param string|array $server_name
47      */
48     public function modify($server_name)
49     {
50         $subdomain = null;
51         $domain = null;
52         $tld = null;
53 
54         if (is_array($server_name))
55         {
56             list($subdomain, $domain, $tld) = $server_name;
57         }
58         else
59         {
60             $parts = explode('.', $server_name);
61 
62             if (count($parts) > 1)
63             {
64                 $tld = array_pop($parts);
65             }
66 
67             if (count($parts) > 1)
68             {
69                 $domain = array_pop($parts);
70             }
71 
72             $subdomain = implode('.', $parts);
73         }
74 
75         $this->subdomain = $subdomain;
76         $this->domain = $domain;
77         $this->tld = $tld;
78     }
79 }
Autodoc API documentation generated by ApiGen 2.8.0