Oroboros Core
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • None
  • oroboros
    • core
      • abstracts
        • adapters
        • bootstrap
        • controllers
        • libraries
          • auth
          • bootstrap
          • cache
          • codex
          • config
          • container
          • data
          • database
          • dns
          • entity
          • enum
          • error
          • event
          • extension
          • file
          • flags
          • hooks
          • job
          • logger
          • manager
          • message
          • prototype
          • request
          • response
          • routine
          • shell
          • startup
          • stream
          • template
          • uri
          • utility
          • validation
            • workers
          • worker
        • models
        • patterns
          • behavioral
          • creational
        • utilities
          • exception
            • cache
            • container
          • http
        • views
      • interfaces
        • adapters
          • interpreters
          • sdk
        • api
          • adapters
          • bootstrap
          • controllers
          • psr
        • contract
          • adapters
          • bootstrap
          • codex
          • components
          • controllers
          • data
          • entities
          • errors
          • events
          • extensions
          • jobs
          • libraries
            • auth
            • cache
            • config
            • container
            • enum
            • file
            • flags
            • hooks
            • module
            • promise
            • record
            • request
            • response
            • server
            • shutdown
            • site
            • stream
            • template
            • theme
            • uri
          • models
          • patterns
            • behavioral
            • concurrency
            • creational
            • structural
          • routes
          • routines
            • bootload
            • declarative
            • procedural
            • subsystem
          • services
            • consumer
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
            • provider
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
          • utilities
            • datetime
            • exception
              • cache
              • container
            • filebase
            • http
            • math
            • parser
            • regex
            • session
          • views
        • enumerated
          • environment
          • flags
          • http
          • views
        • libraries
          • manager
          • worker
      • libraries
        • api
        • codex
        • container
        • enum
          • http
        • file
        • hooks
        • logger
        • math
        • psr4
        • request
        • response
        • stream
        • uri
      • patterns
        • creational
      • traits
        • adapters
        • bootstrap
        • codex
        • components
        • controllers
        • data
        • entities
        • events
        • extensions
        • jobs
        • libraries
          • container
          • file
          • request
          • response
          • stream
          • uri
        • models
        • modules
        • patterns
          • behavioral
          • concurrency
          • creational
          • structural
        • routes
        • services
        • utilities
          • core
            • api
            • config
            • contract
              • contract
            • enum
            • environment
            • routines
          • datetime
          • error
          • exception
          • filebase
          • hooks
          • html
          • http
          • logic
          • math
          • parsers
          • regex
          • session
        • views
      • utilities
        • exception
          • cache
          • container
        • http
      • views
    • tests
      • patterns
        • creational
      • psr
        • psr7
      • utilities
        • exception
  • PasswordCompat
    • binary
  • PHP

Traits

  • CookieTrait
  • HeaderTrait
  • ProtocolTrait
  • RequestHeaderTrait
  • RequestMethodTrait
  • ResponseHeaderTrait
  • StatusCodeTrait

Trait StatusCodeTrait

Provides a simple means for representing a status code as an object.

Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.

In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.

3rd parties using this package are not expected to follow this approach,

but ALL of our internal class and logic structure does.

Direct Known Users

oroboros\core\abstracts\utilities\http\AbstractStatusCode

Indirect Known Users

oroboros\core\utilities\http\StatusCode

Namespace: oroboros\core\traits\utilities\http
Package: oroboros\core\utilities
Category: contract-interfaces
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/contract_interface.md
Located at core/traits/utilities/http/StatusCodeTrait.php

Methods summary

public
# __construct( integer $code = 200 )

Instantiates an object representing a valid http status code, as defined in \oroboros\core\interfaces\enumerated\http\StatusCodes

Instantiates an object representing a valid http status code, as defined in \oroboros\core\interfaces\enumerated\http\StatusCodes

Parameters

$code
(optional) Sets the status code that the object represents.

Throws

oroboros\core\utilities\exception\InvalidArgumentException
if an invalid status code is passed.
public string
# __toString( )

Returns the status code message when the object is cast to a string.

Returns the status code message when the object is cast to a string.

Returns

string
public integer
# getCode( )

Returns the status code

Returns the status code

Returns

integer
public string
# getMessage( )

Returns the current status code title.

Returns the current status code title.

Returns

string
public
# setMessage( mixed $message )

Sets a custom status code title. If this method is not called, the default value will be used.

Sets a custom status code title. If this method is not called, the default value will be used.

Parameters

$message
Must be either a string, scalar, or any value that can be cast to a non-empty string (eg: object that has method __toString)

Throws

oroboros\core\utilities\exception\InvalidArgumentException
if a value is passed that cannot resolve to a string that is not empty
protected
# _initializeStatusCode( integer $code, $message = null )

Initializes the status code object.

Initializes the status code object.

Parameters

$code
$message

Throws

oroboros\core\utilities\exception\InvalidArgumentException
if the provided code is not valid.
private
# _getValidStatusCodes( )

Initializes the list of valid status codes for the current class, if it has not already occurred.

Initializes the list of valid status codes for the current class, if it has not already occurred.

private
# _checkStatusCode( integer $code )

Checks if a status code is valid. Will attempt to cast to int if it is scalar and not an integer.

Checks if a status code is valid. Will attempt to cast to int if it is scalar and not an integer.

Parameters

$code

Throws

oroboros\core\utilities\exception\InvalidArgumentException
if the status code is not valid.
private
# _setCustomStatusCodeMessage( scalar|object $message )

Sets a custom status code message. Any scalar value may be passed or any object implementing __toString. The result will be cast to a string if it is not already.

Sets a custom status code message. Any scalar value may be passed or any object implementing __toString. The result will be cast to a string if it is not already.

Parameters

$message
Must be a scalar value or an object with __toString

Throws

oroboros\core\utilities\exception\InvalidArgumentException

Properties summary

private integer $_status_code

Represents the status code value.

Represents the status code value.

# 200
private string $_status_code_title

Represents the status code message.

Represents the status code message.

#
private static oroboros\core\enum\http\StatusCodes $_status_codes_valid

Represents the possible valid status codes.

Represents the possible valid status codes.

#
private static string $_status_codes_enumerator

Represents the validation enumerator used to check whether a status code is valid or not.

Represents the validation enumerator used to check whether a status code is valid or not.

# '\\oroboros\\core\\libraries\\enum\\http\\StatusCodes'
Oroboros Core API documentation generated by ApiGen