Window Inverse

Spoova is a url-loose framework because it handles url comparison as a non-strict type. This means that a url "Home" and "home" are regarded to mean the same thing. There are certain situations that developers may want to be strict in defining window urls, especially in situations where urls are generated using base64_encode() function. In this case, handling case sensitive urls might be an issue. In order to fix this issue, spoova introduces two approaches which can be used to define case sensitive urls.

SELF::STRICT
The SELF::STRICT key, when defined on a shutter, will set all urls to case sensitive. The value must be set as a boolean of true. Once declared within a shutter, the shutter will remember to set all urls to case sensitive unless an inverse is declared which naturally negates the SELF::STRICT key.
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {

        self::call($this, [

            'home/user' => 'root',    // case sensitive url
            
            'home/profile' => 'root', // case sensitive url

             SELF::STRICT => true,    // set all urls as case sensitive

        ])

    }
    
  }


Inverse operator (!)
The inverse operator is an operator that negates the default case-sensitivity or case-insensitivity behaviour of a shutter method that is applied on urls. By default, shutters don't check for case sensitivity of urls. However, the previous subheading shows that this can be modified. In certain cases where case-sensitivity check is needed to be applied only on specific urls, the inverse operator is the best tool to achieve this. An example is shown below:
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {

        self::call($this, [

            'home/user' => 'root',     // case insensitive url
            
            '!home/profile' => 'root', // case sensitive url (inverse)

        ])

    }
    
  }

In certain situations where we already applied a SELF::STRICT option to generally make urls become case sensitive, we can reverse this behaviour by also using the inverse operator.
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {

        self::call($this, [

            SELF::STRICT => true, // set all urls as case-sensitive
            
            'home/user' => 'root', // case sensitive url
            
            '!home/pro' => 'root', // case insensitive url (inverse)

        ])

    }
    
  }

The examples above best explains the behavior of the inverse operator on the urls. In the first code example, the natural shutter behavior was altered using the inverse operator. Likewise, in the second code example, the behavior of SELF::STRICT on urls was altered using the same operator. It is important to note that the window() method has also been integerated with the inverse method. Hence, the inverse operator can be used within the window method, for example, as window('!:user'). This is shown below.
  <?php 

  use Window;

  class Home extends Window {
    
    function __construct() {

        self::call($this, [

            window(':user') => 'root', // case sensitive "home/user"
            
            window('!:pro') => 'root', // case insensitive "home/pro"

            SELF::STRICT => true, // set all urls as strict except inverse

        ])

    }
    
  }

In the sample above, the window function will understand to return the value with the inverse operator as its first character. For example, assuming our root entry point on a window url is home, then while window(':user') will return home/user which will be compared as case-insensitive, window('!:user') will return !home/user which will be compared as a case-sensitive url unless this behaviour is inversely altered with SELF::STRICT constant. In the sample above, the SELF::STRICT option was set as true which will negate the default behaviour. Hence, window(':user') will become case-sensitive while the window('!:user') will become case-insensitive. Also, note that the SELF::STRICT inverse behaviour only affect shutters. Function such as invoke(), windowExcludes() and windowIncludes() will respond in their own individual default ways.

Applying the inverse with window index resolver v2.5+
The window index resolver character "@" is usually applied to the window() function to ensure that a index page url always return the index name even if it is not defined in the current url. When working with inverse urls, we can supply this character by only after the inverse operator has been defined. This means that the inverse operator preceeds the index resolver. A sample format is shown below:
  window('!@root:HoMe')
                            
In the sample above, assuming the current url resembles the format http://{domain}/ which by default is expected to point to an index route, then if window(':') is equivalent to an empty string because no root name was defined on the url above, then window('@root:') will properly assign the name "index" even if not defined. However, as in the case of window('@root:HoMe'), when working on index routes, this will be equivalent to index/HoMe which is case-insensitive while the window('!@root:HoMe') will specify that the url is case-sensitive. However, it is important to note that in order to fix case-sensitity of window roots, this operation can only be done with a map file. More information can also be found on map files here.