diff --git a/CHANGELOG.md b/CHANGELOG.md index dce653e..8ed816b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# 0.1.2 (04.04.2016) + +## Enhancements +- #64 Refresh product. +- #108 Edit products. +- #112 Add more product attributes. +- #117 Log into files and enhance logging. + +## Features +- #114 Return and validate error if error occurs. + # 0.1.1 (22.02.2016) ## Features diff --git a/build/epages-rest-php-0.1.2.phar b/build/epages-rest-php-0.1.2.phar new file mode 100644 index 0000000..eb1ea6e Binary files /dev/null and b/build/epages-rest-php-0.1.2.phar differ diff --git a/build/epages-rest-php-0.1.2.phar.bz2 b/build/epages-rest-php-0.1.2.phar.bz2 new file mode 100644 index 0000000..9510549 Binary files /dev/null and b/build/epages-rest-php-0.1.2.phar.bz2 differ diff --git a/build/epages-rest-php-0.1.2.phar.gz b/build/epages-rest-php-0.1.2.phar.gz new file mode 100644 index 0000000..ac57dc4 Binary files /dev/null and b/build/epages-rest-php-0.1.2.phar.gz differ diff --git a/build/epages-rest-php.phar b/build/epages-rest-php.phar index 968a545..eb1ea6e 100644 Binary files a/build/epages-rest-php.phar and b/build/epages-rest-php.phar differ diff --git a/build/epages-rest-php.phar.bz2 b/build/epages-rest-php.phar.bz2 new file mode 100644 index 0000000..9510549 Binary files /dev/null and b/build/epages-rest-php.phar.bz2 differ diff --git a/build/epages-rest-php.phar.gz b/build/epages-rest-php.phar.gz new file mode 100644 index 0000000..ac57dc4 Binary files /dev/null and b/build/epages-rest-php.phar.gz differ diff --git a/doc/404.html b/doc/404.html index bb9013e..4c848ca 100644 --- a/doc/404.html +++ b/doc/404.html @@ -49,6 +49,9 @@

Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    diff --git a/doc/class-ep6.ContactInformation.html b/doc/class-ep6.ContactInformation.html index cdde7e1..5fe3025 100644 --- a/doc/class-ep6.ContactInformation.html +++ b/doc/class-ep6.ContactInformation.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class ContactInformation

    -

    This is the contact information object of the shop.

    +

    This is the Contact Information object of the shop.

    @@ -108,7 +112,9 @@

    Class ContactInformation

    ep6\ContactInformation uses - ep6\InformationTrait + ep6\Information, + + ep6\ErrorReporting
    @@ -138,9 +144,13 @@

    Class ContactInformation

    0.1.1 The object can be echoed.
    Since: 0.1.1 Unstatic variables.
    + Since: + 0.1.2 Add error reporting.
    See: InformationTrait This trait has all information needed objects.
    - Located at shopobjects/information/ContactInformation.class.php + See: + ErrorReporting This trait gives the error reporting functionality.
    + Located at shopobjects/information/ContactInformation.class.php
    @@ -148,133 +158,34 @@

    Class ContactInformation

    - - - - - - - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + - + - - - - -
    Methods summary
    - public - - String|null - - -
    - # - getDefaultTitle( ) - -
    -

    Gets the title in the default localization.

    -
    - - -
    public - String|null + String
    - # - getTitle( ) + # + __toString( )
    -

    Gets the title.

    +

    Prints the Contact Information object as a string.

    -
    - public - - String|null - - -
    - # - getDefaultShortDescription( ) - -
    -

    Gets the short description in the default localization.

    -
    - -

    Since

    - 0.0.0
    - 0.1.0 Deprecated because the Locale is everytime the configured Locale.
    - 0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    + 0.1.1
    public @@ -307,21 +213,21 @@

    Api

    - # - getShortDescription( ) + # + getAddress( )
    -

    Gets the short description.

    +

    Gets the address.

    -

    Api

    -
    -
    - - -
    -
    - public - - String|null - - -
    - # - getDefaultCompany( ) - -
    -

    Gets the company in the default localization.

    -
    - -
    # - getCompany( ) + getCompany( )

    Gets the company.

    @@ -433,59 +287,7 @@

    Since

    0.1.0 Use a reload function.
    0.1.0 Use the default Locale.
    0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    -
    - - -
    -
    - public - - String|null - - -
    - # - getDefaultContactPerson( ) - -
    -

    Gets the contact person in the default localization.

    -
    - -
    # - getContactPerson( ) + getContactPerson( )

    Gets the contact person.

    @@ -531,59 +333,7 @@

    Since

    0.1.0 Use a reload function.
    0.1.0 Use the default Locale.
    0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    -
    - - -
    -
    - public - - String|null - - -
    - # - getDefaultContactPersonJobTitle( ) - -
    -

    Gets the job title of the contact person in the default localization.

    -
    - -
    # - getContactPersonJobTitle( ) + getContactPersonJobTitle( )

    Gets the job title of the contact person.

    @@ -629,66 +379,14 @@

    Since

    0.1.0 Use a reload function.
    0.1.0 Use the default Locale.
    0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    - public - - String|null - - -
    - # - getDefaultAddress( ) - -
    -

    Gets the address in the default localization.

    -
    - - -
    public @@ -699,21 +397,21 @@

    Api

    - # - getAddress( ) + # + getEmail( )
    -

    Gets the address.

    +

    Gets the email.

    -

    Api

    -
    -
    - - -
    -
    - public - - String|null - - -
    - # - getDefaultPhone( ) - -
    -

    Gets the phone number in the default localization.

    -
    - -
    # - getPhone( ) + getPhone( )

    Gets the phone number.

    @@ -825,16 +471,14 @@

    Since

    0.1.0 Use a reload function.
    0.1.0 Use the default Locale.
    0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    public @@ -845,24 +489,21 @@

    Api

    - # - getDefaultEmail( ) + # + getShortDescription( )
    -

    Gets the email in the default localization.

    +

    Gets the short description.

    public @@ -895,21 +535,21 @@

    Api

    - # - getEmail( ) + # + getTitle( )
    -

    Gets the email.

    +

    Gets the title.

    -

    Api

    -
    + 0.1.2 Add error reporting.
    - public - - String - - -
    - # - __toString( ) - -
    -

    Prints the Information object as a string.

    -
    - -
    - - + + + +
    Methods used from ep6\Information
    + getDescription(), + getName(), + getNavigationCaption() +
    - - - +
    Methods used from ep6\InformationTraitMethods used from ep6\ErrorReporting
    - getDefaultDescription(), - getDefaultName(), - getDefaultNavigationCaption(), - getDescription(), - getName(), - getNavigationCaption() + error(), + errorMessage(), + errorNumber()
    @@ -1008,7 +606,7 @@

    Api

    String - RESTPATH + RESTPATH
    diff --git a/doc/class-ep6.Currencies.html b/doc/class-ep6.Currencies.html index 11682cc..3952c15 100644 --- a/doc/class-ep6.Currencies.html +++ b/doc/class-ep6.Currencies.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -103,6 +107,15 @@

    Class Currencies

    This is the static class for the currencies in the shop.

    +
    +
    +ep6\Currencies + + uses + ep6\ErrorReporting + +
    +
    @@ -115,7 +128,7 @@

    Class Currencies

    Namespace: ep6
    - Package: ep6\Shopobjects
    + Author: David Pauli contact@david-pauli.de
    @@ -127,9 +140,9 @@

    Class Currencies

    0.1.0 Add configured used Currency.
    Since: 0.1.1 Now the object is echoable.
    - Example: - examples\handleWithCurrencies.php Handle with currencies.
    - Located at shopobjects/Currencies.class.php + Since: + 0.1.2 Add error reporting.
    + Located at shopobjects/Currencies.class.php
    @@ -137,29 +150,33 @@

    Class Currencies

    - + - +
    Methods summary
    public static - + The
    - # - resetValues( ) + # + getCurrency( )
    -

    This function resets all curencies values.

    +

    Gets the configured Currency.

    Since

    - 0.0.0
    - 0.1.0 Reset used Currency.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    @@ -191,7 +205,7 @@

    Api

    # - getDefault( ) + getDefault( )

    Gets the default currency.

    @@ -216,9 +230,7 @@

    Since

    0.0.0
    0.1.0 Use a reload function.
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    @@ -237,7 +249,7 @@

    Api

    # - getItems( ) + getItems( )

    Gets the activated currencies.

    @@ -262,42 +274,36 @@

    Since

    0.0.0
    0.1.0 Use a reload function.
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    public static - The +
    - # - getCurrency( ) + # + resetValues( )
    -

    Gets the configured Currency.

    +

    This function resets all curencies values.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.0 Reset used Currency.
    + 0.1.2 Add error reporting.
    @@ -328,7 +333,7 @@

    Api

    # - setCurrency( String $currency ) + setCurrency( String $currency )

    Sets the configured Currency.

    @@ -357,9 +362,7 @@

    Author

    Since

    0.1.0
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    @@ -369,6 +372,16 @@

    Api

    + + + + + +
    Methods used from ep6\ErrorReporting
    + error(), + errorMessage(), + errorNumber() +
    @@ -382,7 +395,7 @@

    Api

    String - RESTPATH + RESTPATH
    diff --git a/doc/class-ep6.ErrorReporting.html b/doc/class-ep6.ErrorReporting.html new file mode 100644 index 0000000..dc7dd8e --- /dev/null +++ b/doc/class-ep6.ErrorReporting.html @@ -0,0 +1,309 @@ + + + + + + Trait ep6\ErrorReporting + + + + + + +
    + +
    + +
    + + + + + + diff --git a/doc/class-ep6.HTTPRequestMethod.html b/doc/class-ep6.HTTPRequestMethod.html index d768f79..7758f0d 100644 --- a/doc/class-ep6.HTTPRequestMethod.html +++ b/doc/class-ep6.HTTPRequestMethod.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,9 +104,9 @@

    Class HTTPRequestMethod

    -

    The HTTP request 'enum'.

    +

    The HTTP Request 'enum'.

    -

    This are the possible HTTP request methods..

    +

    This are the possible HTTP Request Methods.

    @@ -123,7 +127,7 @@

    Class HTTPRequestMethod

    David Pauli contact@david-pauli.de
    Since: 0.0.1
    - Located at util/RESTClient.class.php + Located at util/HTTPRequestMethod.enum.php
    @@ -144,7 +148,7 @@

    Class HTTPRequestMethod

    String - GET + GET
    @@ -168,7 +172,7 @@

    Class HTTPRequestMethod

    String - POST + POST
    @@ -192,7 +196,7 @@

    Class HTTPRequestMethod

    String - PUT + PUT
    @@ -216,7 +220,7 @@

    Class HTTPRequestMethod

    String - DELETE + DELETE
    @@ -240,7 +244,7 @@

    Class HTTPRequestMethod

    String - PATCH + PATCH
    diff --git a/doc/class-ep6.Image.html b/doc/class-ep6.Image.html index 70a0dde..ce6e21e 100644 --- a/doc/class-ep6.Image.html +++ b/doc/class-ep6.Image.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -123,9 +127,7 @@

    Class Image

    0.0.0
    Since: 0.1.1 Now the object can be echoed.
    - Api -
    - Located at shopobjects/image/Image.class.php + Located at shopobjects/image/Image.class.php
    @@ -145,20 +147,20 @@

    Class Image

    # - __construct( String $url ) + __construct( String $url )
    -

    To create a new image object use this constructor with the original URL.

    +

    To create a new Image object use this constructor with the original URL.

    - + public @@ -187,21 +189,23 @@

    Since

    - # - getOriginURL( ) + # + __toString( )
    -

    Gets the original URL of the image.

    +

    Prints the Image object as a string.

    Since

    - 0.0.0
    + 0.1.1
    - + public @@ -229,23 +233,21 @@

    Since

    - # - __toString( ) + # + getOriginURL( )
    -

    Prints the Image object as a string.

    +

    Gets the original URL of the Image.

    Since

    - 0.1.1
    + 0.0.0
    diff --git a/doc/class-ep6.Information.html b/doc/class-ep6.Information.html new file mode 100644 index 0000000..0fd4f6d --- /dev/null +++ b/doc/class-ep6.Information.html @@ -0,0 +1,363 @@ + + + + + + Trait ep6\Information + + + + + + + + +
    + + + + + + diff --git a/doc/class-ep6.InputValidator.html b/doc/class-ep6.InputValidator.html index 25bbdf6..19c6f77 100644 --- a/doc/class-ep6.InputValidator.html +++ b/doc/class-ep6.InputValidator.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -123,9 +127,7 @@

    Class InputValidator

    0.0.0
    Since: 0.1.0 Add function to add float values.
    - Example: - examples\useValidator.php Test input values with the static Validator object.
    - Located at util/InputValidator.class.php + Located at util/InputValidator.class.php
    @@ -133,7 +135,7 @@

    Class InputValidator

    - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + + + + + + +
    Methods summary
    public static @@ -144,26 +146,26 @@

    Class InputValidator

    - # - isHost( String $parameter ) + # + isArray( array $parameter )
    -

    Checks whether a parameter is a host.

    +

    Checks whether a parameter is an array.

    public static @@ -194,15 +193,15 @@

    Api

    - # - isShop( String $parameter ) + # + isAuthToken( String $parameter )
    -

    Checks whether a parameter is a shop.

    +

    Checks whether a parameter is a OAuth authentification token.

    public static @@ -244,17 +240,15 @@

    Api

    - # - isAuthToken( String $parameter ) + # + isCurrency( String $parameter )
    -

    Checks whether a parameter is a OAuth authentification token. -TODO: Finalize this function.

    +

    Checks whether a parameter is a currency string.

    public static @@ -296,15 +287,15 @@

    Api

    - # - isLocale( String $parameter ) + # + isEmpty( String $parameter )
    -

    Checks whether a parameter is a localization string.

    +

    Checks whether a paramter is empty or null.

    public static @@ -346,26 +335,26 @@

    Api

    - # - isCurrency( String $parameter ) + # + isEmptyArray( mixed[] $parameter )
    -

    Checks whether a parameter is a currency string.

    +

    Checks whether an array is empty or null.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.0
    public static @@ -396,26 +382,28 @@

    Api

    - # - isRequestMethod( String $parameter ) + # + isEmptyArrayKey( mixed[] $array, String $key )
    -

    Checks whether a parameter is a HTTP request method.

    +

    Checks whether an array key is unset.

    Since

    - 0.0.0
    - 0.1.0 Use HTTPRequestMethod enum.
    -
    -

    Api

    -
    + 0.1.0
    public static @@ -447,26 +431,26 @@

    Api

    - # - isOutputRessource( String $parameter ) + # + isFloat( float $parameter )
    -

    Checks whether a parameter is an output ressource.

    +

    Checks whether a parameter is a float.

    Since

    - 0.0.0
    - 0.1.0 Use LogOutput enum.
    -
    -

    Api

    -
    + 0.1.0
    public static @@ -498,15 +478,15 @@

    Api

    - # - isLogLevel( String $parameter ) + # + isHost( String $parameter )
    -

    Checks whether a parameter is a log level.

    +

    Checks whether a parameter is a host.

    public static @@ -549,26 +525,26 @@

    Api

    - # - isRESTCommand( String $parameter ) + # + isInt( integer $parameter )
    -

    Checks whether a parameter is a REST command.

    +

    Checks whether a parameter is an int.

    @@ -600,7 +573,7 @@

    Api

    # - isJSON( String $parameter ) + isJSON( String $parameter )

    Checks whether a parameter is a JSON string.

    @@ -630,15 +603,12 @@

    Since

    0.0.0
    -

    Api

    -
    -
    public static @@ -649,30 +619,26 @@

    Api

    - # - isRangedInt( integer $parameter, integer|null $minimum = null, integer|null $maximum = null ) + # + isLocale( String $parameter )
    -

    Checks whether a parameter is an int with a range.

    +

    Checks whether a parameter is a localization string.

    public static @@ -703,30 +666,26 @@

    Api

    - # - isRangedFloat( float $parameter, float|null $minimum = null, float|null $maximum = null ) + # + isLogLevel( String $parameter )
    -

    Checks whether a parameter is a float with a range.

    +

    Checks whether a parameter is a log level.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.0 Use LogLevel enum.
    @@ -758,7 +715,7 @@

    Api

    # - isProductDirection( String $parameter ) + isProductDirection( String $parameter )

    Checks whether a parameter is a product sort direction.

    @@ -788,8 +745,52 @@

    Since

    0.0.0
    -

    Api

    + + +
    +
    + public static + + boolean + + +
    + # + isProductId( String $parameter ) + +
    +

    Checks whether a parameter is a valid product id.

    +
    + +
    # - isProductSort( String $parameter ) + isProductSort( String $parameter )

    Checks whether a parameter is a product sort parameter.

    @@ -838,15 +839,12 @@

    Since

    0.0.0
    -

    Api

    -
    -
    public static @@ -857,15 +855,15 @@

    Api

    - # - isProductId( String $parameter ) + # + isOutputRessource( String $parameter )
    -

    Checks whether a parameter is a valid product id.

    +

    Checks whether a parameter is an output ressource.

    public static @@ -907,26 +904,30 @@

    Api

    - # - isFloat( float $parameter ) + # + isRangedFloat( float $parameter, float|null $minimum = null, float|null $maximum = null )
    -

    Checks whether a parameter is a float.

    +

    Checks whether a parameter is a float with a range.

    public static @@ -957,21 +955,25 @@

    Api

    - # - isInt( integer $parameter ) + # + isRangedInt( integer $parameter, integer|null $minimum = null, integer|null $maximum = null )
    -

    Checks whether a parameter is an int.

    +

    Checks whether a parameter is an int with a range.

    public static @@ -1007,26 +1006,26 @@

    Api

    - # - isArray( array $parameter ) + # + isRESTCommand( String $parameter )
    -

    Checks whether a parameter is an array.

    +

    Checks whether a parameter is a REST command.

    public static @@ -1057,15 +1053,15 @@

    Api

    - # - isEmpty( String $parameter ) + # + isRequestMethod( String $parameter )
    -

    Checks whether a paramter is empty or null.

    +

    Checks whether a parameter is a HTTP request method.

    public static @@ -1108,26 +1101,26 @@

    Api

    - # - isEmptyArray( mixed[] $parameter ) + # + isShop( String $parameter )
    -

    Checks whether an array is empty or null.

    +

    Checks whether a parameter is a shop.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    public static @@ -1158,28 +1148,26 @@

    Api

    - # - isEmptyArrayKey( mixed[] $array, String $key ) + # + isString( String $parameter )
    -

    Checks whether an array key is unset.

    +

    Checks whether a parameter is a string.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.2
    diff --git a/doc/class-ep6.JSONHandler.html b/doc/class-ep6.JSONHandler.html index 8295f7c..436bf99 100644 --- a/doc/class-ep6.JSONHandler.html +++ b/doc/class-ep6.JSONHandler.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -103,6 +107,15 @@

    Class JSONHandler

    This is a small simple handler to convert JSON into an array and otherwise.

    +
    +
    +ep6\JSONHandler + + uses + ep6\ErrorReporting + +
    +
    @@ -121,7 +134,9 @@

    Class JSONHandler

    David Pauli contact@david-pauli.de
    Since: 0.0.0
    - Located at util/JSONHandler.class.php + Since: + 0.1.2 Add error reporting.
    + Located at util/JSONHandler.class.php
    @@ -129,37 +144,37 @@

    Class JSONHandler

    - + - +
    Methods summary
    public static - mixed[] + String
    - # - parseJSON( String $JSON ) + # + createJSON( mixed[] $array )
    -

    Call this function with the JSON in parameter.

    +

    Call this function to create a JSON string from a array.

    public static - String + mixed[]
    - # - createJSON( mixed[] $array ) + # + parseJSON( String $JSON )
    -

    Call this function to create a JSON string from a array.

    +

    Call this function with the JSON in parameter.

    + + + + + +
    Methods used from ep6\ErrorReporting
    + error(), + errorMessage(), + errorNumber() +
    diff --git a/doc/class-ep6.Locales.html b/doc/class-ep6.Locales.html index 3d4425d..4c1945e 100644 --- a/doc/class-ep6.Locales.html +++ b/doc/class-ep6.Locales.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -103,6 +107,15 @@

    Class Locales

    This is the static class for the localization.

    +
    +
    +ep6\Locales + + uses + ep6\ErrorReporting + +
    +
    @@ -127,9 +140,9 @@

    Class Locales

    0.1.0 Add configured used Locale.
    Since: 0.1.1 Now the object is echoable.
    - Example: - examples\handleWithLocales.php Handle with locales.
    - Located at shopobjects/Locales.class.php + Since: + 0.1.2 Add error reporting.
    + Located at shopobjects/Locales.class.php
    @@ -137,29 +150,33 @@

    Class Locales

    - + - + - + - +
    Methods summary
    public static - + The
    - # - resetValues( ) + # + getDefault( )
    -

    This function resets all locales values.

    +

    Gets the default localization.

    public static @@ -190,21 +205,21 @@

    Api

    - # - getDefault( ) + # + getItems( )
    -

    Gets the default localization.

    +

    Gets the activated localizations.

    public static @@ -236,21 +249,21 @@

    Api

    - # - getItems( ) + # + getLocale( )
    -

    Gets the activated localizations.

    +

    Gets the configured Locale.

    Since

    - 0.0.0
    - 0.1.0 Use a reload function.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    public static - The +
    - # - getLocale( ) + # + resetValues( )
    -

    Gets the configured Locale.

    +

    This function resets all locales values.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.0 Reset used Locale.
    + 0.1.2 Add error reporting.
    @@ -328,7 +333,7 @@

    Api

    # - setLocale( String $locale ) + setLocale( String $locale )

    Sets the configured Locale.

    @@ -357,9 +362,7 @@

    Author

    Since

    0.1.0
    -
    -

    Api

    -
    + 0.1.2 Add error reporting.
    @@ -369,6 +372,16 @@

    Api

    + + + + + +
    Methods used from ep6\ErrorReporting
    + error(), + errorMessage(), + errorNumber() +
    @@ -382,7 +395,7 @@

    Api

    String - RESTPATH + RESTPATH
    diff --git a/doc/class-ep6.LogLevel.html b/doc/class-ep6.LogLevel.html index 42419a3..b8c42fb 100644 --- a/doc/class-ep6.LogLevel.html +++ b/doc/class-ep6.LogLevel.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class LogLevel

    -

    The log level 'enum'.

    +

    The Log Level 'enum'.

    Use this to define which log messages should be printed.

    @@ -123,7 +127,7 @@

    Class LogLevel

    David Pauli contact@david-pauli.de
    Since: 0.0.1
    - Located at util/Logger.class.php + Located at util/LogLevel.enum.php
    @@ -144,7 +148,7 @@

    Class LogLevel

    String - NOTIFICATION + NOTIFICATION
    @@ -168,7 +172,7 @@

    Class LogLevel

    String - WARNING + WARNING
    @@ -192,7 +196,7 @@

    Class LogLevel

    String - ERROR + ERROR
    @@ -216,7 +220,7 @@

    Class LogLevel

    String - NONE + NONE
    @@ -240,7 +244,7 @@

    Class LogLevel

    String - FORCE + FORCE
    diff --git a/doc/class-ep6.LogOutput.html b/doc/class-ep6.LogOutput.html index 1595419..a8529b2 100644 --- a/doc/class-ep6.LogOutput.html +++ b/doc/class-ep6.LogOutput.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class LogOutput

    -

    The log output 'enum'.

    +

    The Log Output 'enum'.

    Use this to define where the log messages should be printed.

    @@ -123,7 +127,9 @@

    Class LogOutput

    David Pauli contact@david-pauli.de
    Since: 0.0.1
    - Located at util/Logger.class.php + Since: + 0.1.2
    + Located at util/LogOutput.enum.php
    @@ -144,7 +150,7 @@

    Class LogOutput

    String - SCREEN + SCREEN
    @@ -163,6 +169,30 @@

    Class LogOutput

    String + + FILE + + +
    + +
    + + +
    +
    + # + "FILE" +
    +
    diff --git a/doc/class-ep6.Logger.html b/doc/class-ep6.Logger.html index 44e6126..e9fc7dc 100644 --- a/doc/class-ep6.Logger.html +++ b/doc/class-ep6.Logger.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -123,9 +127,9 @@

    Class Logger

    0.0.0
    Since: 0.0.1 Use LogLevel and LogOutput
    - Example: - examples\logMessages.php Use the Logger to log messages.
    - Located at util/Logger.class.php + Since: + 0.1.2 Add functionality to print into files.
    + Located at util/Logger.class.php
    @@ -133,35 +137,36 @@

    Class Logger

    - + - + - + - + - + + + + + + + - + - + - + - + - + - + diff --git a/doc/class-ep6.PriceWithQuantity.html b/doc/class-ep6.PriceWithQuantity.html index 4d37e80..b315f8f 100644 --- a/doc/class-ep6.PriceWithQuantity.html +++ b/doc/class-ep6.PriceWithQuantity.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class PriceWithQuantity

    -

    This is the class for prices which has a quantity.

    +

    This is the class for Prices which has a Quantity.

    @@ -119,6 +123,10 @@

    Class PriceWithQuantity

    +
    +

    Direct known subclasses

    + ep6\ProductPriceWithQuantity +
    @@ -159,14 +167,14 @@

    Class PriceWithQuantity

    - + - + - + @@ -364,6 +366,59 @@

    Overrides

    +
    Methods summary
    - public static + public - + String
    - # - notify( String $message ) + # + __toString( )
    -

    This function prints notifications.

    +

    Prints the Logger object as a string.

    public static @@ -191,15 +192,15 @@

    Api

    - # - warning( String $message ) + # + error( String $message )
    -

    This function prints warnings.

    +

    This function prints errors.

    public static @@ -238,15 +237,15 @@

    Api

    - # - error( String $message ) + # + force( String $message )
    -

    This function prints errors.

    +

    This function definitly prints the message.

    public static @@ -285,15 +282,15 @@

    Api

    - # - force( String $message ) + # + notify( String $message )
    -

    This function definitly prints the message.

    +

    This function prints notifications.

    # - setLogLevel( ep6\LogLevel $level ) + setLogLevel( ep6\LogLevel $level )

    This function sets the log level.

    @@ -360,9 +355,7 @@

    Since

    0.0.0
    0.0.1 Use LogLevel enum.
    0.0.3 Set php error reporting automatically in developing systems.
    -
    -

    Api

    -
    + 0.1.2 epages-rest-php log level will not take effect in PHP log level.
    @@ -381,7 +374,7 @@

    Api

    # - setOutput( ep6\LogOutput $out ) + setOutput( ep6\LogOutput $out )

    This function sets the output ressource.

    @@ -408,52 +401,93 @@

    Since

    0.0.0
    0.0.1 Use LogOutput enum.
    -

    Api

    -
    -
    - public + public static - String +
    - # - __toString( ) + # + setOutputFile( String $filename )
    -

    Prints the Logger object as a string.

    +

    This function sets the output file.

    +
    + public static + + + + +
    + # + warning( String $message ) + +
    +

    This function prints warnings.

    +
    + + @@ -151,20 +160,20 @@

    Direct known subclasses

    # - __construct( mixed[] $priceParameter ) + __construct( mixed[] $priceParameter )
    -

    This is the constructor of the price object.

    +

    This is the constructor of the Price object.

    -

    Api

    -
    -
    public - float + String
    - # - getAmount( ) + # + __toString( )
    -

    Returns the amount.

    +

    Prints the Price object as a string.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.1
    public - String + float
    - # - getTaxType( ) + # + getAmount( )
    -

    Returns the tax type.

    +

    Returns the amount.

    @@ -289,7 +291,7 @@

    Api

    # - getCurrency( ) + getCurrency( )

    Returns the currency.

    @@ -314,9 +316,6 @@

    Since

    0.1.0
    -

    Api

    -
    -
    @@ -334,7 +333,7 @@

    Api

    # - getFormatted( ) + getFormatted( )

    Returns the formatted price with currency.

    @@ -367,7 +366,7 @@

    Api

    public @@ -378,23 +377,21 @@

    Api

    - # - __toString( ) + # + getTaxType( )
    -

    Prints the Price object as a string.

    +

    Returns the tax type.

    Since

    - 0.1.1
    + 0.1.0
    @@ -451,77 +448,77 @@

    Since

    protected String|null - $taxType + $currency
    -

    The tax type of the price.

    +

    The curreny of the price.

    - # + # null
    protected String|null - $currency + $formatted
    -

    The curreny of the price.

    +

    The formatted price with currency.

    - # + # null
    protected String|null - $formatted + $taxType
    -

    The formatted price with currency.

    +

    The tax type of the price.

    - # + # null
    # - __construct( mixed[] $priceParameter, mixed[] $quantityParameter ) + __construct( mixed[] $priceParameter, mixed[] $quantityParameter )
    -

    This is the constructor of the price with quantity object.

    +

    This is the constructor of the Price With Quantity object.

    public @@ -209,21 +217,23 @@

    Overrides

    - # - getQuantityAmount( ) + # + __toString( )
    -

    Returns the quantity amount.

    +

    Prints the Price With Quantity object as a string.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.1
    +

    Overrides

    +
    public @@ -254,26 +263,21 @@

    Api

    - # - getQuantityUnit( String $locale,… ) + # + getQuantityAmount( )
    -

    Returns the quantity unit.

    +

    Returns the quantity amount.

    public @@ -305,23 +305,26 @@

    Api

    - # - __toString( ) + # + getQuantityUnit( String $locale,… )
    -

    Prints the Price with quantity object as a string.

    +

    Returns the quantity unit.

    Since

    - 0.1.1
    + 0.1.0
    + 0.1.1 No locale parameter is needed.
    -

    Overrides

    -
    + + + + + + + + + + + + + +
    Properties summary
    + protected + integer|null + + $quantityAmount + +
    +

    The quantity amount.

    +
    + + +
    +
    + # + null +
    +
    + protected + String|null + + $quantityUnit + +
    +

    The quantity unit.

    +
    + + +
    +
    + # + null +
    +
    diff --git a/doc/class-ep6.PrivacyPolicyInformation.html b/doc/class-ep6.PrivacyPolicyInformation.html index 13720d6..6961b03 100644 --- a/doc/class-ep6.PrivacyPolicyInformation.html +++ b/doc/class-ep6.PrivacyPolicyInformation.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class PrivacyPolicyInformation

    -

    The privacy policy information.

    +

    The Privacy Policy Information.

    @@ -108,7 +112,9 @@

    Class PrivacyPolicyInformation

    ep6\PrivacyPolicyInformation uses - ep6\InformationTrait + ep6\Information, + + ep6\ErrorReporting
    @@ -134,73 +140,38 @@

    Class PrivacyPolicyInformation

    0.1.1 This object is now echoable.
    Since: 0.1.1 Unstatic every attributes.
    + Since: + 0.1.2 Add error reporting.
    See: InformationTrait This trait has all information needed objects.
    - Located atshopobjects/information/PrivacyPolicyInformation.class.php + See: + ErrorReporting This trait gives the error reporting functionality.
    + Located atshopobjects/information/PrivacyPolicyInformation.class.php
    -
    Properties inherited from ep6\Price
    - - - - - - +
    Methods summary
    - public - - String - - -
    - # - __toString( ) - -
    -

    Prints the Information object as a string.

    -
    - - -
    + + +
    Methods used from ep6\Information
    + __toString(), + getDescription(), + getName(), + getNavigationCaption() +
    - - - +
    Methods used from ep6\InformationTraitMethods used from ep6\ErrorReporting
    - getDefaultDescription(), - getDefaultName(), - getDefaultNavigationCaption(), - getDescription(), - getName(), - getNavigationCaption() + error(), + errorMessage(), + errorNumber()
    @@ -217,7 +188,7 @@

    Since

    String - RESTPATH + RESTPATH
    diff --git a/doc/class-ep6.Product.html b/doc/class-ep6.Product.html index 28f8808..a68d414 100644 --- a/doc/class-ep6.Product.html +++ b/doc/class-ep6.Product.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,9 +104,18 @@

    Class Product

    -

    This is the product class for a product in the shop.

    +

    This is the product class for a Product in the shop.

    +
    +
    +ep6\Product + + uses + ep6\ErrorReporting + +
    +
    @@ -139,7 +152,11 @@

    Class Product

    0.1.1 Don't use locale parameter in get functions.
    Since: 0.1.1 Unstatic every attributes.
    - Located at shopobjects/product/Product.class.php + Since: + 0.1.2 Insert the Setters.
    + Since: + 0.1.2 Add error reporting.
    + Located at shopobjects/product/Product.class.php
    @@ -159,14 +176,14 @@

    Class Product

    # - __construct( mixed[] $productParameter ) + __construct( mixed[] $productParameter )
    -

    This is the constructor of the product.

    +

    This is the constructor of the Product.

    -

    Api

    -
    + 0.1.2 Exclude the REST request to the load() function.
    + 0.1.2 Add error reporting.
    - + public @@ -207,21 +223,23 @@

    Api

    - # - getID( ) + # + __toString( )
    -

    Returns the product id.

    +

    Prints the Product object as a string.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.1
    - + public - String + float|null
    - # - getName( ) + # + decreaseStockLevel( float $step = 1.0 )
    -

    Returns the name in a specific localization.

    +

    Decreases the stock level.

    Since

    - 0.0.0
    - 0.1.0 Use a default Locale.
    - 0.1.1 Fix to call function without locale parameter.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    - + public - String + boolean
    - # - getShortDescription( ) + # + delete( )
    -

    Returns the short description in a specific localization.

    +

    Deletes itself.

    Since

    - 0.0.0
    - 0.1.0 Use a default Locale.
    - 0.1.1 Fix to call function without locale parameter.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.1 Unstatic every attributes.
    + 0.1.2 Add error reporting.
    - + public - String + ProductAttributes|null
    - # - getDescription( ) + # + getAttribute( integer $key )
    -

    Returns the description in a specific localization.

    +

    Returns the product attributes.

    Since

    - 0.0.0
    - 0.1.0 Use a default Locale.
    - 0.1.1 Fix to call function without locale parameter.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    - + public - boolean + ProductAttributes[]
    - # - isForSale( ) + # + getAttributes( )
    -

    Returns true if it is for sale.

    +

    Returns the product attributes.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.1 Unstatic every attributes.
    + 0.1.2 Add error reporting.
    - + public - boolean + String
    - # - isSpecialOffer( ) + # + getAvailibilityText( )
    -

    Returns true if it is a special offer.

    +

    Returns the availibility text.

    - + public - String + ep6\ProductPrice
    - # - getAvailibilityText( ) + # + getBasePrice( )
    -

    Returns the availibility text in a specific localization.

    +

    Returns the base price.

    Since

    - 0.0.0
    - 0.1.0 Use a default Locale.
    - 0.1.1 Fix to call function without locale parameter.
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    - + public - ep6\Image + ep6\ProductPrice
    - # - getSmallImage( ) + # + getDepositPrice( )
    -

    Returns the small image.

    +

    Returns the deposit price.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    - + public - ep6\Image + String
    - # - getMediumImage( ) + # + getDescription( )
    -

    Returns the medium image.

    +

    Returns the description.

    - + public - ep6\Image + String
    - # - getLargeImage( ) + # + getEAN( )
    -

    Returns the large image.

    +

    Returns the EAN.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.2
    - + public - ep6\Image + ep6\ProductPrice
    - # - getHotDealImage( ) + # + getEcoParticipationPrice( )
    -

    Returns the hot deal image.

    +

    Returns the eco participation price.

    Since

    - 0.0.0
    -
    -

    Api

    -
    + 0.1.0
    + 0.1.2 Add error reporting.
    - + public - ep6\PriceWithQuantity + String
    - # - getPrice( ) + # + getEnergyLabelsString( )
    -

    Returns the price with quantity.

    +

    Returns the energy labels string.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.2
    - + public - ep6\Price + String
    - # - getDepositPrice( ) + # + getEssentialFeatures( )
    -

    Returns the deposit price.

    +

    Returns the essential features.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.2
    - + public - ep6\Price + ep6\Image
    - # - getEcoParticipationPrice( ) + # + getHotDealImage( )
    -

    Returns the eco participation price.

    +

    Returns the hot deal image.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.2 Add error reporting.
    - + public - ep6\Price + String
    - # - getWithDepositPrice( ) + # + getID( )
    -

    Returns the with deposit price.

    +

    Returns the product id.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.2 Add error reporting.
    - + public - ep6\Price + ep6\Image
    - # - getManufactorPrice( ) + # + getLargeImage( )
    -

    Returns the manufactor price.

    +

    Returns the large image.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.2 Add error reporting.
    - + public - ep6\Price + String
    - # - getBasePrice( ) + # + getManufacturer( )
    -

    Returns the base price.

    +

    Returns the name of the manufacturer.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.2
    - + public - ep6\ProductSlideshow + ep6\ProductPrice
    - # - getSlideshow( ) + # + getManufacturerPrice( )
    -

    Returns the slideshow.

    +

    Returns the manufacturer price.

    - + public - ProductAttributes[] + ep6\Image
    - # - getAttributes( ) + # + getMediumImage( )
    -

    Returns the product attributes.

    +

    Returns the medium image.

    Since

    - 0.1.0
    - 0.1.1 Unstatic every attributes.
    -
    -

    Api

    -
    + 0.0.0
    + 0.1.2 Add error reporting.
    - + public - ProductAttributes|null + String
    - # - getAttribute( integer $key ) + # + getName( )
    -

    Returns the product attributes.

    +

    Returns the name.

    Since

    - 0.1.0
    + 0.0.0
    + 0.1.0 Use a default Locale.
    + 0.1.1 Fix to call function without locale parameter.
    + 0.1.2 Add error reporting.
    +
    + + +
    + + + + + + public + + integer + + + + +
    + # + getNumberOfSearchKeywords( ) + +
    +

    Returns the amount of search keywords.

    +
    + +
    - + public - float|null + ep6\ProductPriceWithQuantity
    - # - getStockLevel( ) + # + getPrice( )
    -

    Returns the stock level.

    +

    Returns the product price with quantity.

    +
    + + + + + public + + String + + + + +
    + # + getProductNumber( ) + +
    +

    Returns the product number.

    +
    + +
    - + public - float|null + String
    - # - increaseStockLevel( float $step = 1.0 ) + # + getSearchKeyword( integer $number )
    -

    Increases the stock level.

    +

    Returns the search keyword.

    Since

    - 0.1.0
    + 0.1.2
    +
    + + +
    + + + + + + public + + String + + + + +
    + # + getShortDescription( ) + +
    +

    Returns the short description.

    +
    + +
    - + public - float|null + ep6\ProductSlideshow
    - # - decreaseStockLevel( float $step = 1.0 ) + # + getSlideshow( )
    -

    Decreases the stock level.

    +

    Returns the slideshow.

    +
    + + + + + public + + ep6\Image + + + + +
    + # + getSmallImage( ) + +
    +

    Returns the small image.

    +
    + +
    - + public - boolean + float|null
    - # - delete( ) + # + getStockLevel( )
    -

    Deletes itself.

    +

    Returns the stock level.

    - + public @@ -1313,23 +1450,21 @@

    Since

    - # - __toString( ) + # + getUPC( )
    -

    Prints the Product object as a string.

    +

    Returns the UPC.

    Since

    - 0.1.1
    + 0.1.2
    - + + + + public + + ep6\ProductPrice + + + + +
    + # + getWithDepositPrice( ) + +
    +

    Returns the with deposit price.

    +
    + + +
    + + + + + public + + float|null + + + + +
    + # + increaseStockLevel( float $step = 1.0 ) + +
    +

    Increases the stock level.

    +
    + + +
    + + + + + public + + boolean + + + + +
    + # + isForSale( ) + +
    +

    Returns true if it is for sale.

    +
    + + +
    + + + + + public + + boolean + + + + +
    + # + isSpecialOffer( ) + +
    +

    Returns true if it is a special offer.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setDescription( String $description ) + +
    +

    Sets the description of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setEAN( String $ean ) + +
    +

    Sets the EAN of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setEnergyLabelsString( String $energyLabelsString ) + +
    +

    Sets the energy labels string of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setEssentialFeatures( String $essentialFeatures ) + +
    +

    Sets the essential features of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setManufacturer( String $manufacturer ) + +
    +

    Sets the manufacturer of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setName( String $name ) + +
    +

    Sets the name of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setNumber( String $number ) + +
    +

    Sets the product number of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setSearchKeywords( String $searchKeywords ) + +
    +

    Sets the search keywords of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setShortDescription( String $shortDescription ) + +
    +

    Sets the short description of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + setUPC( String $upc ) + +
    +

    Sets the UPC of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetDescription( ) + +
    +

    Deletes the description value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetEAN( ) + +
    +

    Deletes the EAN value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetEnergyLabelsString( ) + +
    +

    Deletes the energy labels string value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetEssentialFeatures( ) + +
    +

    Deletes the essential features value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetManufacturer( ) + +
    +

    Deletes the manufacturer value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetName( ) + +
    +

    Deletes the name value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetSearchKeywords( ) + +
    +

    Deletes the search keywords of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetShortDescription( ) + +
    +

    Deletes the short description value of the product.

    +
    + + +
    + + + + + public + + + + + + +
    + # + unsetUPC( ) + +
    +

    Deletes the UPC value of the product.

    +
    + + +
    + + + + + + + + + +
    Methods used from ep6\ErrorReporting
    + error(), + errorMessage(), + errorNumber() +
    @@ -1362,7 +2456,7 @@

    Since

    String - RESTPATH + RESTPATH
    @@ -1386,7 +2480,7 @@

    Since

    String - RESTPATH_ATTRIBUTES + RESTPATH_ATTRIBUTES
    @@ -1410,7 +2504,7 @@

    Since

    String - RESTPATH_STOCKLEVEL + RESTPATH_STOCKLEVEL
    diff --git a/doc/class-ep6.ProductAttribute.html b/doc/class-ep6.ProductAttribute.html index 5e0051c..7d885ab 100644 --- a/doc/class-ep6.ProductAttribute.html +++ b/doc/class-ep6.ProductAttribute.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -100,7 +104,7 @@

    Class ProductAttribute

    -

    This is the product attribute class which saves all attributes of a product.

    +

    This is the Product Attribute class which saves all attributes of a product.

    @@ -123,9 +127,7 @@

    Class ProductAttribute

    0.1.0
    Since: 0.1.1 The object can be echoed.
    - Api -
    - Located at shopobjects/product/ProductAttribute.class.php + Located at shopobjects/product/ProductAttribute.class.php
    @@ -145,7 +147,7 @@

    Class ProductAttribute

    # - __construct( mixed[] $attribute ) + __construct( mixed[] $attribute )

    This function gets the product attributes.

    @@ -171,40 +173,39 @@

    Since

    0.1.0
    -

    Api

    -
    -
    - + public - String|null + String
    - # - getInternName( ) + # + __toString( )
    -

    Returns the intern name of the attribute.

    +

    Prints the Product attribute object as a string.

    Since

    - 0.1.0
    -
    -

    Api

    -
    + 0.1.1
    - + public @@ -235,21 +233,21 @@

    Api

    - # - getName( ) + # + getInternName( )
    -

    Returns the name of the attribute.

    +

    Returns the intern name of the attribute.

    - + public - boolean + String|null
    - # - isOneValue( ) + # + getName( )
    -

    Returns whether the attribute can one has one value.

    +

    Returns the name of the attribute.

    @@ -326,7 +318,7 @@

    Api

    # - getType( ) + getType( )

    Returns the type of the attribute value.

    @@ -351,9 +343,6 @@

    Since

    0.1.0
    -

    Api

    -
    -
    @@ -371,7 +360,7 @@

    Api

    # - getValues( ) + getValues( )

    Returns the possible values of this attribute.

    @@ -396,42 +385,37 @@

    Since

    0.1.0
    -

    Api

    -
    -
    - + public - String + boolean
    - # - __toString( ) + # + isOneValue( )
    -

    Prints the Product attribute object as a string.

    +

    Returns whether the attribute can one has one value.

    Since

    - 0.1.1
    + 0.1.0
    diff --git a/doc/class-ep6.ProductFilter.html b/doc/class-ep6.ProductFilter.html index 2c91a49..77228a7 100644 --- a/doc/class-ep6.ProductFilter.html +++ b/doc/class-ep6.ProductFilter.html @@ -48,6 +48,9 @@

    Classes

  • Product
  • ProductAttribute
  • ProductFilter
  • +
  • ProductPrice
  • +
  • ProductPriceType
  • +
  • ProductPriceWithQuantity
  • ProductSlideshow
  • RESTClient
  • RightsOfWithdrawalInformation
  • @@ -59,7 +62,8 @@

    Classes

    Traits

    @@ -103,6 +107,15 @@

    Class ProductFilter

    This is a product filter class to search products via the REST call "product".

    +
    +
    +ep6\ProductFilter + + uses + ep6\ErrorReporting + +
    +
    @@ -125,9 +138,9 @@

    Class ProductFilter

    0.1.0 Use a default Locale and Currency.
    Since: 0.1.1 The object can be echoed now.
    - Example: - examples\createProductFilter.php Create and use the product filter.
    - Located at shopobjects/product/ProductFilter.class.php + Since: + 0.1.2 Add error reporting.
    + Located at shopobjects/product/ProductFilter.class.php
    @@ -147,7 +160,7 @@

    Class ProductFilter

    # - __construct( String[] $productFilterParameter = array() ) + __construct( String[] $productFilterParameter = array() )

    This is the constructor to prefill the product filter.

    @@ -173,99 +186,49 @@

    Since

    0.0.1
    -

    Api

    -
    -
    - + public - + String
    - # - setProductFilter( String[] $productFilterParameter ) + # + __toString( )
    -

    Fill the product filter with a array.

    +

    Prints the Product attribute object as a string.

    -
    - - - - - public - - - - - +

    Prints the Product attribute object as a string.

    -
    - # - printFilter( ) +

    This function returns the setted values of the Product attribute object.

    -
    -

    This function prints the filter in a FORCE message.

    -
    - - + public @@ -1020,26 +919,26 @@

    Api

    - # - setCategoryID( String $categoryID ) + # + setQ( String $q )
    -

    This function sets the category ID to show.

    +

    This function sets the query search string to show.

    - + public - String + boolean
    - # - getCategoryID( ) + # + setResultsPerPage( integer $resultsPerPage )
    -

    This function gets the category ID string.

    +

    This function sets the results per page to show.

    - + public @@ -1117,26 +1017,26 @@

    Api

    - # - setID( String $productID ) + # + setSort( String $sort )
    -

    This function add a product ID from filter.

    +

    This function sets the order parameter to show.

    @@ -151,7 +166,7 @@

    Class RESTClient

    # - connect( String $host, String $shop, String $authToken, boolean $isssl ) + connect( String $host, String $shop, String $authToken = null, boolean $isssl = null )

    The constructor for the main class.

    @@ -183,16 +198,15 @@

    Since

    0.0.0
    0.0.1 Use disconnect function on wrong parameters.
    -
    -

    Api

    -
    + 0.1.2 Throw warning with wrong parameters.
    + 0.1.2 Add error reporting.
    - + public static @@ -203,20 +217,16 @@

    Api

    - # - printStatus( ) + # + disconnect( )
    -

    This function prints the status of the REST client in a FORCE Logger message.

    +

    Disconnects and deletes all configuration data.

    - + public static - String + mixed[]
    - # - sendWithLocalization( String $command, String $locale, mixed[] $postfields = array() ) + # + send( String $command, String[] $postfields = array() )
    -

    This send function sends a special command to the REST server.

    +

    This send function sends a special command to the REST server with additional parameter.

    - + public static - mixed[] + String
    - # - send( String $command, String[] $postfields = array() ) + # + sendWithLocalization( String $command, String $locale, mixed[] $postfields = array() )
    -

    This send function sends a special command to the REST server with additional parameter.

    +

    This send function sends a special command to the REST server.

    - + diff --git a/doc/source-class-ep6.Currencies.html b/doc/source-class-ep6.Currencies.html index 89659df..94a6f82 100644 --- a/doc/source-class-ep6.Currencies.html +++ b/doc/source-class-ep6.Currencies.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -111,173 +115,192 @@

    Traits

    14: * @since 0.1.0 Add a timestamp to save the next allowed REST call. 15: * @since 0.1.0 Add configured used Currency. 16: * @since 0.1.1 Now the object is echoable. - 17: * @package ep6 + 17: * @since 0.1.2 Add error reporting. 18: * @subpackage Shopobjects - 19: * @example examples\handleWithCurrencies.php Handle with currencies. - 20: */ - 21: class Currencies { - 22: - 23: /** @var String The REST path for currencies. */ - 24: const RESTPATH = "currencies"; - 25: - 26: /** @var String|null Space to save the default currencies. */ - 27: private static $DEFAULT = null; - 28: - 29: /** @var String[] Space to save the possible currencies. */ - 30: private static $ITEMS = array(); - 31: - 32: /** @var String|null Configured Locale. */ - 33: private static $USED = null; - 34: - 35: /** @var int Timestamp in ms when the next request needs to be done. */ - 36: private static $NEXT_REQUEST_TIMESTAMP = 0; - 37: - 38: /** - 39: * Gets the default and possible currencies of the shop. - 40: * - 41: * @author David Pauli <contact@david-pauli.de> - 42: * @since 0.0.0 - 43: * @since 0.1.0 Use HTTPRequestMethod enum - 44: * @since 0.1.0 Save timestamp of the last request. - 45: * @since 0.1.0 Add configured used Currency. - 46: * @api - 47: */ - 48: private static function load() { - 49: - 50: // if request method is blocked - 51: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { - 52: return; - 53: } + 19: */ + 20: class Currencies { + 21: + 22: use ErrorReporting; + 23: + 24: /** @var String The REST path for currencies. */ + 25: const RESTPATH = "currencies"; + 26: + 27: /** @var String|null Space to save the default currencies. */ + 28: private static $DEFAULT = null; + 29: + 30: /** @var int Timestamp in ms when the next request needs to be done. */ + 31: private static $NEXT_REQUEST_TIMESTAMP = 0; + 32: + 33: /** @var String[] Space to save the possible currencies. */ + 34: private static $ITEMS = array(); + 35: + 36: /** @var String|null Configured Locale. */ + 37: private static $USED = null; + 38: + 39: /** + 40: * Gets the configured Currency. + 41: * + 42: * @author David Pauli <contact@david-pauli.de> + 43: * @return The configured Currency which is used in REST calls. + 44: * @since 0.1.0 + 45: * @since 0.1.2 Add error reporting. + 46: */ + 47: public static function getCurrency() { + 48: + 49: self::errorReset(); + 50: self::reload(); + 51: + 52: return self::$USED; + 53: } 54: - 55: $content = RESTClient::send(self::RESTPATH); - 56: - 57: // if respond is empty or there are no default AND items element - 58: if (InputValidator::isEmptyArrayKey($content, "default") || - 59: InputValidator::isEmptyArrayKey($content, "items")) { - 60: Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); - 61: return; - 62: } - 63: - 64: // reset values - 65: self::resetValues(); - 66: - 67: // save the default currency - 68: self::$DEFAULT = $content["default"]; - 69: - 70: // parse the possible currencies - 71: self::$ITEMS = $content["items"]; - 72: - 73: // set the configured shop Locale if it is empty. - 74: if (InputValidator::isEmpty(self::$USED)) { - 75: self::$USED = $content["default"]; - 76: } - 77: - 78: // update timestamp when make the next request - 79: $timestamp = (int) (microtime(true) * 1000); - 80: self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; - 81: } + 55: /** + 56: * Gets the default currency. + 57: * + 58: * @author David Pauli <contact@david-pauli.de> + 59: * @return The default currencies of the shop. + 60: * @since 0.0.0 + 61: * @since 0.1.0 Use a reload function. + 62: * @since 0.1.2 Add error reporting. + 63: */ + 64: public static function getDefault() { + 65: + 66: self::errorReset(); + 67: self::reload(); + 68: + 69: return self::$DEFAULT; + 70: } + 71: + 72: /** + 73: * Gets the activated currencies. + 74: * + 75: * @author David Pauli <contact@david-pauli.de> + 76: * @return The possible currencies of the shop. + 77: * @since 0.0.0 + 78: * @since 0.1.0 Use a reload function. + 79: * @since 0.1.2 Add error reporting. + 80: */ + 81: public static function getItems() { 82: - 83: /** - 84: * This function resets all curencies values. - 85: * - 86: * @author David Pauli <contact@david-pauli.de> - 87: * @since 0.0.0 - 88: * @since 0.1.0 Reset used Currency. - 89: * @api - 90: */ - 91: public static function resetValues() { - 92: - 93: self::$DEFAULT = null; - 94: self::$ITEMS = array(); - 95: self::$USED = null; - 96: } - 97: - 98: /** - 99: * This function checks whether a reload is needed. -100: * -101: * @author David Pauli <contact@david-pauli.de> -102: * @since 0.1.0 -103: * @api -104: */ -105: private static function reload() { -106: -107: $timestamp = (int) (microtime(true) * 1000); -108: -109: // if the value is empty -110: if (!InputValidator::isEmpty(self::$DEFAULT) && -111: !InputValidator::isEmpty(self::$ITEMS) && -112: self::$NEXT_REQUEST_TIMESTAMP > $timestamp) { -113: return; -114: } -115: -116: self::load(); -117: } -118: -119: /** -120: * Gets the default currency. -121: * -122: * @author David Pauli <contact@david-pauli.de> -123: * @since 0.0.0 -124: * @since 0.1.0 Use a reload function. -125: * @api -126: * @return The default currencies of the shop. -127: */ -128: public static function getDefault() { -129: -130: self::reload(); -131: return self::$DEFAULT; -132: } -133: -134: /** -135: * Gets the activated currencies. -136: * -137: * @author David Pauli <contact@david-pauli.de> -138: * @since 0.0.0 -139: * @since 0.1.0 Use a reload function. -140: * @api -141: * @return The possible currencies of the shop. -142: */ -143: public static function getItems() { -144: -145: self::reload(); -146: return self::$ITEMS; -147: } -148: -149: /** -150: * Gets the configured Currency. -151: * -152: * @author David Pauli <contact@david-pauli.de> -153: * @since 0.1.0 -154: * @api -155: * @return The configured Currency which is used in REST calls. -156: */ -157: public static function getCurrency() { -158: -159: self::reload(); -160: return self::$USED; -161: } -162: -163: /** -164: * Sets the configured Currency. -165: * -166: * @author David Pauli <contact@david-pauli.de> -167: * @since 0.1.0 -168: * @api -169: * @param String $currency The new used Locale. -170: * @return boolean True if set the Currency works, false if not. -171: */ -172: public static function setCurrency($currency) { -173: -174: self::reload(); -175: if (array_key_exists($currency, self::$ITEMS)) { -176: self::$USED = $currency; -177: return true; -178: } -179: return false; -180: } -181: -182: } -183: ?> + 83: self::errorReset(); + 84: self::reload(); + 85: + 86: return self::$ITEMS; + 87: } + 88: + 89: /** + 90: * This function resets all curencies values. + 91: * + 92: * @author David Pauli <contact@david-pauli.de> + 93: * @since 0.0.0 + 94: * @since 0.1.0 Reset used Currency. + 95: * @since 0.1.2 Add error reporting. + 96: */ + 97: public static function resetValues() { + 98: + 99: self::errorReset(); +100: +101: self::$DEFAULT = null; +102: self::$ITEMS = array(); +103: self::$USED = null; +104: } +105: +106: /** +107: * Sets the configured Currency. +108: * +109: * @author David Pauli <contact@david-pauli.de> +110: * @param String $currency The new used Locale. +111: * @return boolean True if set the Currency works, false if not. +112: * @since 0.1.0 +113: * @since 0.1.2 Add error reporting. +114: */ +115: public static function setCurrency($currency) { +116: +117: self::errorReset(); +118: self::reload(); +119: +120: if (array_key_exists($currency, self::$ITEMS)) { +121: +122: self::$USED = $currency; +123: return true; +124: } +125: +126: Logger::error("Can't set currency " . $currency . ". It is not available in the shop."); +127: self::errorSet("C-2"); +128: +129: return false; +130: } +131: +132: /** +133: * Gets the default and possible currencies of the shop. +134: * +135: * @author David Pauli <contact@david-pauli.de> +136: * @since 0.0.0 +137: * @since 0.1.0 Use HTTPRequestMethod enum +138: * @since 0.1.0 Save timestamp of the last request. +139: * @since 0.1.0 Add configured used Currency. +140: * @since 0.1.2 Add error reporting. +141: */ +142: private static function load() { +143: +144: // if request method is blocked +145: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { +146: +147: return; +148: } +149: +150: $content = RESTClient::send(self::RESTPATH); +151: +152: // if respond is empty or there are no default AND items element +153: if (InputValidator::isEmptyArrayKey($content, "default") || +154: InputValidator::isEmptyArrayKey($content, "items")) { +155: +156: Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); +157: self::errorSet("C-1"); +158: return; +159: } +160: +161: // reset values +162: self::resetValues(); +163: +164: // save the default currency +165: self::$DEFAULT = $content["default"]; +166: +167: // parse the possible currencies +168: self::$ITEMS = $content["items"]; +169: +170: // set the configured shop Locale if it is empty. +171: if (InputValidator::isEmpty(self::$USED)) { +172: +173: self::$USED = $content["default"]; +174: } +175: +176: // update timestamp when make the next request +177: $timestamp = (int) (microtime(true) * 1000); +178: self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; +179: } +180: +181: /** +182: * This function checks whether a reload is needed. +183: * +184: * @author David Pauli <contact@david-pauli.de> +185: * @since 0.1.0 +186: */ +187: private static function reload() { +188: +189: $timestamp = (int) (microtime(true) * 1000); +190: +191: // if the value is empty +192: if (!InputValidator::isEmpty(self::$DEFAULT) && +193: !InputValidator::isEmpty(self::$ITEMS) && +194: self::$NEXT_REQUEST_TIMESTAMP > $timestamp) { +195: +196: return; +197: } +198: +199: self::load(); +200: } +201: } +202: ?>
    - + diff --git a/doc/source-class-ep6.ErrorReporting.html b/doc/source-class-ep6.ErrorReporting.html new file mode 100644 index 0000000..729e982 --- /dev/null +++ b/doc/source-class-ep6.ErrorReporting.html @@ -0,0 +1,262 @@ + + + + + + + File util/ErrorReporting.trait.php + + + + + + + + +
    + + + + + + diff --git a/doc/source-class-ep6.HTTPRequestMethod.html b/doc/source-class-ep6.HTTPRequestMethod.html index e5117d3..15aa28f 100644 --- a/doc/source-class-ep6.HTTPRequestMethod.html +++ b/doc/source-class-ep6.HTTPRequestMethod.html @@ -4,7 +4,7 @@ - File util/RESTClient.class.php + File util/HTTPRequestMethod.enum.php @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -95,311 +99,31 @@

    Traits

    -
      1: <?php
    -  2: /**
    -  3:  * This file represents the REST client class.
    -  4:  *
    -  5:  * @author David Pauli <contact@david-pauli.de>
    -  6:  * @since 0.0.0
    -  7:  * @since 0.0.1 Add HTTPRequestMethod enum.
    -  8:  */
    -  9: namespace ep6;
    - 10: /**
    - 11:  * This is the pure REST client. It is used in a static way.
    - 12:  *
    - 13:  * @author David Pauli <contact@david-pauli.de>
    - 14:  * @since 0.0.0
    - 15:  * @since 0.0.3 Use HTTPRequestMethod enum.
    - 16:  * @since 0.1.0 Add a recommended wait time for the next request.
    - 17:  * @since 0.1.1 Now the object is printable via echo.
    - 18:  * @since 0.1.1 Add function to change the wait time for next REST request.
    - 19:  * @since 0.1.1 Set $HOST and $SHOP to default value null.
    - 20:  * @package ep6
    - 21:  * @subpackage Util
    - 22:  */
    - 23: class RESTClient {
    - 24: 
    - 25:     /** @var String|null The ePages host to connect. */
    - 26:     private static $HOST = null;
    - 27: 
    - 28:     /** @var String|null The refered ePages ahop. */
    - 29:     private static $SHOP = null;
    - 30: 
    - 31:     /** @var String|null The authentification token (access token). */
    - 32:     private static $AUTHTOKEN = null;
    - 33: 
    - 34:     /** @var boolean|null You use https or http? Default is true. */
    - 35:     private static $ISSSL = true;
    - 36: 
    - 37:     /** @var boolean Boolean to log whether the client is connected or not. */
    - 38:     private static $ISCONNECTED = false;
    - 39: 
    - 40:     /** @var HTTPRequestMethod The request method of the REST call. */
    - 41:     private static $HTTP_REQUEST_METHOD = HTTPRequestMethod::GET;
    - 42: 
    - 43:     /** @var String The path to the REST ressource in the shop. */
    - 44:     const PATHTOREST = "rs/shops";
    - 45: 
    - 46:     /** @var String The accepted value of the response. */
    - 47:     const HTTP_ACCEPT = "application/vnd.epages.v1+json";
    - 48: 
    - 49:     /** @var String The content type of the request. */
    - 50:     const HTTP_CONTENT_TYPE = "application/json";
    - 51: 
    - 52:     /** @var int The time in ms the shop object should wait until the next request. */
    - 53:     public static $NEXT_RESPONSE_WAIT_TIME = 600;
    - 54: 
    - 55:     /**
    - 56:      * The constructor for the main class.
    - 57:      *
    - 58:      * @author David Pauli <contact@david-pauli.de>
    - 59:      * @since 0.0.0
    - 60:      * @since 0.0.1 Use disconnect function on wrong parameters.
    - 61:      * @api
    - 62:      * @param String $host The epages host to connect.
    - 63:      * @param String $shop The refered ePages shop.
    - 64:      * @param String $authToken The authentificaton token to connect via REST.
    - 65:      * @param boolean $isssl True, if you use SSL, false if not. Default value is true.
    - 66:      */
    - 67:     public static function connect($host, $shop, $authToken, $isssl) {
    - 68: 
    - 69:         // check parameter
    - 70:         if (!InputValidator::isHost($host) ||
    - 71:             !InputValidator::isShop($shop)) {
    - 72:             self::disconnect();
    - 73:             return false;
    - 74:         }
    - 75: 
    - 76:         self::$HOST = $host;
    - 77:         self::$SHOP = $shop;
    - 78:         self::$ISSSL = $isssl;
    - 79:         self::$AUTHTOKEN = $authToken;
    - 80:         self::$ISCONNECTED = true;
    - 81: 
    - 82:         return true;
    - 83:     }
    - 84: 
    - 85:     /**
    - 86:      * This function prints the status of the REST client in a FORCE Logger message.
    - 87:      *
    - 88:      * @author David Pauli <contact@david-pauli.de>
    - 89:      * @since 0.0.0
    - 90:      * @since 0.1.1 Echo the object itself to see all values setted.
    - 91:      * @deprecated Echo the object itself to see all values setted.
    - 92:      */
    - 93:     public static function printStatus() {
    - 94: 
    - 95:         Logger::force(self);
    - 96:     }
    - 97: 
    - 98:     /**
    - 99:      * This send function sends a special command to the REST server.
    -100:      *
    -101:      * @author David Pauli <contact@david-pauli.de>
    -102:      * @since 0.0.0
    -103:      * @api
    -104:      * @param String command The path which is requested in the REST client.
    -105:      * @param String locale The localization to get.
    -106:      * @param mixed[] postfields Add specific parameters to the REST server.
    -107:      * @return String The returned JSON object or null if something goes wrong.
    -108:      */
    -109:     public static function sendWithLocalization($command, $locale, $postfields = array()) {
    -110: 
    -111:         // cheeck parameters
    -112:         if (!InputValidator::isLocale($locale)) {
    -113:             return null;
    -114:         }
    -115:         return self::send($command . "?locale=" . $locale, $postfields);
    -116:     }
    -117: 
    -118:     /**
    -119:      * This send function sends a special command to the REST server with additional parameter.
    -120:      *
    -121:      * @author David Pauli <contact@david-pauli.de>
    -122:      * @since 0.0.0
    -123:      * @since 0.0.1 Use HTTPRequestMethod enum.
    -124:      * @since 0.1.0 Allow empty message body if the status code is 204.
    -125:      * @api
    -126:      * @param String command The path which is requested in the REST client.
    -127:      * @param String[] postfields Add specific parameters to the REST server.
    -128:      * @return mixed[] The returned elements as array.
    -129:      */
    -130:     public static function send($command, $postfields = array()) {
    -131: 
    -132:         if (!InputValidator::isRESTCommand($command) ||
    -133:             !self::$ISCONNECTED ||
    -134:             !InputValidator::isArray($postfields)) {
    -135:             return null;
    -136:         }
    -137: 
    -138:         $protocol = self::$ISSSL ? "https" : "http";
    -139:         $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command;
    -140: 
    -141:         $headers = array(
    -142:             "Accept: " . self::HTTP_ACCEPT,
    -143:             "Content-Type: " . self::HTTP_CONTENT_TYPE);
    -144: 
    -145:         if (InputValidator::isAuthToken(self::$AUTHTOKEN)) {
    -146:             array_push($headers, "Authorization: Bearer " . self::$AUTHTOKEN);
    -147:         }
    -148: 
    -149:         $curl = curl_init($url);
    -150: 
    -151:         curl_setopt($curl, CURLOPT_FAILONERROR, 1);                             // show full errors
    -152:         curl_setopt($curl, CURLOPT_FORBID_REUSE, 0);                            // connection can be opened
    -153:         curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0);                           // no new connection required
    -154:         curl_setopt($curl, CURLOPT_NOBODY, 0);                                  // show body
    -155:         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);                          // get response as string
    -156:         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);                          // no connection timeout
    -157:         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0);                       // no connection timeout
    -158:         curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);       // cURL will choose the http version
    -159:         curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);         // understand ipv4 and ipv6
    -160: 
    -161:         if (self::$ISSSL) {
    -162:             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);                      // don't check the peer ssl cerrificate
    -163:             curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
    -164:             curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
    -165:             curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);    // default ssl version
    -166:         }
    -167:         else {
    -168:             curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
    -169:             curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP);
    -170:         }
    -171: 
    -172:         switch (self::$HTTP_REQUEST_METHOD) {
    -173:             case HTTPRequestMethod::GET:
    -174:                 curl_setopt($curl, CURLOPT_HTTPGET, 1);
    -175:                 break;
    -176:             case HTTPRequestMethod::POST:
    -177:                 $JSONpostfield = JSONHandler::createJSON($postfields);
    -178:                 curl_setopt($curl, CURLOPT_POST, 1);
    -179:                 curl_setopt($curl, CURLOPT_POSTREDIR, 0);   // don't post on redirects
    -180:                 curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
    -181:                 break;
    -182:             case HTTPRequestMethod::PUT:
    -183:                 $JSONpostfield = JSONHandler::createJSON($postfields);
    -184:                 array_push($headers, "Content-Length: " . strlen($JSONpostfield));
    -185:                 curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
    -186:                 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
    -187:                 break;
    -188:             case HTTPRequestMethod::DELETE:
    -189:                 $JSONpostfield = JSONHandler::createJSON($postfields);
    -190:                 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
    -191:                 curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
    -192:                 break;
    -193:             case HTTPRequestMethod::PATCH:
    -194:                 $JSONpostfield = JSONHandler::createJSON($postfields);
    -195:                 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
    -196:                 curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
    -197:                 break;
    -198:         }
    -199: 
    -200:         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    -201: 
    -202:         $response = curl_exec($curl);
    -203:         $info = curl_getinfo($curl);
    -204:         $error = curl_error($curl);
    -205:         curl_close($curl);
    -206: 
    -207:         $logMessage = self::$HTTP_REQUEST_METHOD . " " . $info["url"] . "<br/>"
    -208:                     . "<strong>Response</strong>: " . $info["http_code"] . ": <pre>" . htmlspecialchars($response) . "</pre><br/>"
    -209:                     . "<strong>Content-Type</strong>: " . $info["content_type"] . "<br/>"
    -210:                     . "<strong>Size</strong> (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes<br/>"
    -211:                     . "<strong>Time</strong> (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds<br/>";
    -212:         Logger::notify("<strong>HTTP-SEND</strong>:<br/>" . $logMessage);
    -213: 
    -214:         // if message body is empty this is allowed with 204
    -215:         if (!$response && $info["http_code"]!="204") {
    -216:             Logger::error("Error with send REST client: " .$error);
    -217:             return null;
    -218:         }
    -219:         elseif (!in_array($info["http_code"], array("200", "201", "204"))) {
    -220:             Logger::warning("Get wrong response: " . $info["http_code"]);
    -221:             return null;
    -222:         }
    -223: 
    -224:         return JSONHandler::parseJSON($response);
    -225:     }
    -226: 
    -227:     /**
    -228:      * Sets another request method.
    -229:      *
    -230:      * @author David Pauli <contact@david-pauli.de>
    -231:      * @since 0.0.0
    -232:      * @since 0.1.0 Use HTTPRequestMethod enum.
    -233:      * @api
    -234:      * @param HTTPRequestMethod method The request method the REST client should use.
    -235:      * @return boolean True, if it works, false if not.
    -236:      */
    -237:     public static function setRequestMethod($method) {
    -238:         if (!InputValidator::isRequestMethod($method)) {
    -239:             return false;
    -240:         }
    -241:         self::$HTTP_REQUEST_METHOD = $method;
    -242:         return true;
    -243:     }
    -244: 
    -245:     /**
    -246:      * Disconnects and deletes all configuration data.
    -247:      *
    -248:      * @author David Pauli <contact@david-pauli.de>
    -249:      * @since 0.0.0
    -250:      * @api
    -251:      */
    -252:     public static function disconnect() {
    -253: 
    -254:         self::$HOST = "";
    -255:         self::$SHOP = "";
    -256:         self::$AUTHTOKEN = null;
    -257:         self::$ISCONNECTED = false;
    -258:         self::$ISSSL = true;
    -259:         return true;
    -260:     }
    -261: 
    -262:     /**
    -263:      * Change the time to wait with the next request.
    -264:      *
    -265:      * @author David Pauli <contact@david-pauli.de>
    -266:      * @since 0.1.1
    -267:      * @param int time The time in ms every reload needs to wait until get new information.
    -268:      * @return boolean True if the change works, false if not.
    -269:      * @api
    -270:      */
    -271:     public static function setRequestWaitTime($time) {
    -272: 
    -273:         if (!InputValidator::isRangedInt($time, 0)) {
    -274:             return false;
    -275:         }
    -276: 
    -277:         self::$NEXT_RESPONSE_WAIT_TIME = $time;
    -278:         return true;
    -279:     }
    -280: }
    -281: 
    -282: /**
    -283:  * The HTTP request 'enum'.
    -284:  *
    -285:  * This are the possible HTTP request methods..
    -286:  *
    -287:  * @author David Pauli <contact@david-pauli.de>
    -288:  * @since 0.0.1
    -289:  * @package ep6
    -290:  * @subpackage Util\RESTClient
    -291:  */
    -292: abstract class HTTPRequestMethod {
    -293:     /** @var String Use this for a GET request. **/
    -294:     const GET = "GET";
    -295:     /** @var String Use this for a POST request. **/
    -296:     const POST = "POST";
    -297:     /** @var String Use this for a PUT request. **/
    -298:     const PUT = "PUT";
    -299:     /** @var String Use this for a DELETE request. **/
    -300:     const DELETE = "DELETE";
    -301:     /** @var String Use this for a PATCH request. **/
    -302:     const PATCH = "PATCH";
    -303: }
    -304: 
    -305: ?>
    +
     1: <?php
    + 2: namespace ep6;
    + 3: /**
    + 4:  * The HTTP Request 'enum'.
    + 5:  *
    + 6:  * This are the possible HTTP Request Methods.
    + 7:  *
    + 8:  * @author David Pauli <contact@david-pauli.de>
    + 9:  * @package ep6
    +10:  * @since 0.0.1
    +11:  * @subpackage Util\RESTClient
    +12:  */
    +13: abstract class HTTPRequestMethod {
    +14:     /** @var String Use this for a GET request. **/
    +15:     const GET = "GET";
    +16:     /** @var String Use this for a POST request. **/
    +17:     const POST = "POST";
    +18:     /** @var String Use this for a PUT request. **/
    +19:     const PUT = "PUT";
    +20:     /** @var String Use this for a DELETE request. **/
    +21:     const DELETE = "DELETE";
    +22:     /** @var String Use this for a PATCH request. **/
    +23:     const PATCH = "PATCH";
    +24: }
    +25: ?>
    - + diff --git a/doc/source-class-ep6.Image.html b/doc/source-class-ep6.Image.html index 8564913..2ef75b3 100644 --- a/doc/source-class-ep6.Image.html +++ b/doc/source-class-ep6.Image.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,7 +101,7 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the image class.
    + 3:  * This file represents the Image class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
    @@ -107,53 +111,54 @@ 

    Traits

    10: * This is the image class which is used for images. 11: * 12: * @author David Pauli <contact@david-pauli.de> -13: * @since 0.0.0 -14: * @since 0.1.1 Now the object can be echoed. -15: * @api -16: * @package ep6 -17: * @subpackage Shopobjects\Image -18: */ -19: class Image { -20: -21: /** @var string This is the path to the origin URL. */ -22: private $URL = null; -23: -24: /** -25: * To create a new image object use this constructor with the original URL. -26: * -27: * @author David Pauli <contact@david-pauli.de> +13: * @package ep6 +14: * @since 0.0.0 +15: * @since 0.1.1 Now the object can be echoed. +16: * @subpackage Shopobjects\Image +17: */ +18: class Image { +19: +20: /** @var string This is the path to the origin URL. */ +21: private $URL = null; +22: +23: /** +24: * To create a new Image object use this constructor with the original URL. +25: * +26: * @author David Pauli <contact@david-pauli.de> +27: * @param String $url The origin URL of the Image. 28: * @since 0.0.0 -29: * @param String $url The origin URL of the image. -30: */ -31: public function __construct($url) { +29: */ +30: public function __construct($url) { +31: 32: $this->URL = $url; 33: } 34: 35: /** -36: * Gets the original URL of the image. +36: * Prints the Image object as a string. 37: * -38: * @author David Pauli <contact@david-pauli.de> -39: * @since 0.0.0 -40: * @return String The original URL. -41: */ -42: public function getOriginURL() { -43: return $this->URL; -44: } +38: * This function returns the setted values of the Image object. +39: * +40: * @author David Pauli <contact@david-pauli.de> +41: * @return String The Image as a string. +42: * @since 0.1.1 +43: */ +44: public function __toString() { 45: -46: /** -47: * Prints the Image object as a string. -48: * -49: * This function returns the setted values of the Image object. -50: * -51: * @author David Pauli <contact@david-pauli.de> -52: * @since 0.1.1 -53: * @return String The Image as a string. -54: */ -55: public function __toString() { -56: -57: return "<strong>URL:</strong> " . $this->URL . "<br/>"; -58: } -59: }
    +46: return "<strong>URL:</strong> " . $this->URL . "<br/>"; +47: } +48: +49: /** +50: * Gets the original URL of the Image. +51: * +52: * @author David Pauli <contact@david-pauli.de> +53: * @return String The original URL. +54: * @since 0.0.0 +55: */ +56: public function getOriginURL() { +57: +58: return $this->URL; +59: } +60: }
    - + diff --git a/doc/source-class-ep6.Information.html b/doc/source-class-ep6.Information.html new file mode 100644 index 0000000..b0c1328 --- /dev/null +++ b/doc/source-class-ep6.Information.html @@ -0,0 +1,309 @@ + + + + + + + File shopobjects/information/Information.trait.php + + + + + + + + +
    + + + + + + diff --git a/doc/source-class-ep6.InputValidator.html b/doc/source-class-ep6.InputValidator.html index c466dd6..0195834 100644 --- a/doc/source-class-ep6.InputValidator.html +++ b/doc/source-class-ep6.InputValidator.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -107,349 +111,339 @@

    Traits

    10: * This class, used by a static way, checks whether a value is valid. 11: * 12: * @author David Pauli <contact@david-pauli.de> - 13: * @since 0.0.0 - 14: * @since 0.1.0 Add function to add float values. - 15: * @package ep6 + 13: * @package ep6 + 14: * @since 0.0.0 + 15: * @since 0.1.0 Add function to add float values. 16: * @subpackage Util - 17: * @example examples\useValidator.php Test input values with the static Validator object. - 18: */ - 19: class InputValidator { - 20: - 21: /** - 22: * Checks whether a parameter is a host. - 23: * - 24: * @author David Pauli <contact@david-pauli.de> - 25: * @since 0.0.0 - 26: * @api - 27: * @param String $parameter String to check. - 28: * @return boolean True if the string is a host, false if not. - 29: */ - 30: public static function isHost($parameter) { - 31: - 32: return self::isMatchRegex($parameter, "/^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}/", "host") - 33: && !self::isEmpty($parameter); - 34: } - 35: - 36: /** - 37: * Checks whether a parameter is a shop. - 38: * - 39: * @author David Pauli <contact@david-pauli.de> - 40: * @since 0.0.0 - 41: * @api - 42: * @param String $parameter String to check. - 43: * @return boolean True if the string is a shop, false if not. - 44: */ - 45: public static function isShop($parameter) { - 46: - 47: return !self::isEmpty($parameter); - 48: } - 49: - 50: /** - 51: * Checks whether a parameter is a OAuth authentification token. - 52: * TODO: Finalize this function. - 53: * - 54: * @author David Pauli <contact@david-pauli.de> - 55: * @since 0.0.0 - 56: * @api - 57: * @param String $parameter String to check. - 58: * @return boolean True if the string is a OAuth authentification token, false if not. - 59: */ - 60: public static function isAuthToken($parameter) { - 61: - 62: return !self::isEmpty($parameter); - 63: } - 64: - 65: /** - 66: * Checks whether a parameter is a localization string. - 67: * - 68: * @author David Pauli <contact@david-pauli.de> - 69: * @since 0.0.0 - 70: * @api - 71: * @param String $parameter String to check. - 72: * @return boolean True if the string is a localization string, false if not. - 73: */ - 74: public static function isLocale($parameter) { - 75: - 76: return self::isMatchRegex($parameter, "/^[a-z]{2,4}_[A-Z]{2,3}$/", "Locale") - 77: && !self::isEmpty($parameter); - 78: } - 79: - 80: /** - 81: * Checks whether a parameter is a currency string. - 82: * - 83: * @author David Pauli <contact@david-pauli.de> - 84: * @since 0.0.0 - 85: * @api - 86: * @param String $parameter String to check. - 87: * @return boolean True if the string is a currency string, false if not. - 88: */ - 89: public static function isCurrency($parameter) { - 90: - 91: return self::isMatchRegex($parameter, "/^[A-Z]{3}$/", "Currency") - 92: && !self::isEmpty($parameter); - 93: } - 94: - 95: /** - 96: * Checks whether a parameter is a HTTP request method. - 97: * - 98: * @author David Pauli <contact@david-pauli.de> - 99: * @since 0.0.0 -100: * @since 0.1.0 Use HTTPRequestMethod enum. -101: * @api -102: * @param String $parameter String to check. -103: * @return boolean True if the string is a HTTP request method, false if not. -104: */ -105: public static function isRequestMethod($parameter) { -106: -107: return self::isMatchRegex($parameter, "/^(GET|POST|PUT|DELETE|PATCH)/", "HTTP request method") -108: && !self::isEmpty($parameter); -109: } + 17: */ + 18: class InputValidator { + 19: + 20: /** + 21: * Checks whether a parameter is an array. + 22: * + 23: * @author David Pauli <contact@david-pauli.de> + 24: * @param array $parameter Array to check. + 25: * @return boolean True if the parameter is an array, false if not. + 26: * @since 0.0.0 + 27: */ + 28: public static function isArray($parameter) { + 29: + 30: return is_array($parameter) && !self::isEmpty($parameter); + 31: } + 32: + 33: /** + 34: * Checks whether a parameter is a OAuth authentification token. + 35: * + 36: * @author David Pauli <contact@david-pauli.de> + 37: * @param String $parameter String to check. + 38: * @return boolean True if the string is a OAuth authentification token, false if not. + 39: * @since 0.0.0 + 40: */ + 41: public static function isAuthToken($parameter) { + 42: + 43: return !self::isEmpty($parameter); + 44: } + 45: + 46: /** + 47: * Checks whether a parameter is a currency string. + 48: * + 49: * @author David Pauli <contact@david-pauli.de> + 50: * @param String $parameter String to check. + 51: * @return boolean True if the string is a currency string, false if not. + 52: * @since 0.0.0 + 53: */ + 54: public static function isCurrency($parameter) { + 55: + 56: return self::isMatchRegex($parameter, "/^[A-Z]{3}$/", "Currency") + 57: && !self::isEmpty($parameter); + 58: } + 59: + 60: /** + 61: * Checks whether a paramter is empty or null. + 62: * + 63: * @author David Pauli <contact@david-pauli.de> + 64: * @param String $parameter String to check. + 65: * @return boolean True if the parameter is empty or null, false if not. + 66: * @since 0.0.0 + 67: * @since 0.1.0 Test if the parameter is also the correct type. + 68: */ + 69: public static function isEmpty($parameter) { + 70: + 71: return (is_null($parameter) || ($parameter === "")); + 72: } + 73: + 74: /** + 75: * Checks whether an array is empty or null. + 76: * + 77: * @author David Pauli <contact@david-pauli.de> + 78: * @param mixed[] $parameter Array to check. + 79: * @return boolean True if the array is empty or null, false if not. + 80: * @since 0.1.0 + 81: */ + 82: public static function isEmptyArray($parameter) { + 83: + 84: return (is_null($parameter) || empty($parameter)); + 85: } + 86: + 87: /** + 88: * Checks whether an array key is unset. + 89: * + 90: * @author David Pauli <contact@david-pauli.de> + 91: * @param mixed[] $array Array to check. + 92: * @param String $key Key to exists. + 93: * @return boolean True if the array key is unset, false if not. + 94: * @since 0.1.0 + 95: */ + 96: public static function isEmptyArrayKey($array, $key) { + 97: + 98: return self::isEmptyArray($array) || !array_key_exists($key, $array); + 99: } +100: +101: /** +102: * Checks whether a parameter is a float. +103: * +104: * @author David Pauli <contact@david-pauli.de> +105: * @param float $parameter Float to check. +106: * @return boolean True if the parameter is a float, false if not. +107: * @since 0.1.0 +108: */ +109: public static function isFloat($parameter) { 110: -111: /** -112: * Checks whether a parameter is an output ressource. -113: * -114: * @author David Pauli <contact@david-pauli.de> -115: * @since 0.0.0 -116: * @since 0.1.0 Use LogOutput enum. -117: * @api +111: return is_float($parameter) && !self::isEmpty($parameter); +112: } +113: +114: /** +115: * Checks whether a parameter is a host. +116: * +117: * @author David Pauli <contact@david-pauli.de> 118: * @param String $parameter String to check. -119: * @return boolean True if the string is an output ressource, false if not. -120: */ -121: public static function isOutputRessource($parameter) { -122: -123: return self::isMatchRegex($parameter, "/^(SCREEN)/", "output ressource") -124: && !self::isEmpty($parameter); -125: } -126: -127: /** -128: * Checks whether a parameter is a log level. -129: * -130: * @author David Pauli <contact@david-pauli.de> -131: * @since 0.0.0 -132: * @since 0.1.0 Use LogLevel enum. -133: * @api -134: * @param String $parameter String to check. -135: * @return boolean True if the string is a log level, false if not. -136: */ -137: public static function isLogLevel($parameter) { -138: -139: return self::isMatchRegex($parameter, "/^(NOTIFICATION|WARNING|ERROR|NONE)/", "log level") -140: && !self::isEmpty($parameter); -141: } -142: -143: /** -144: * Checks whether a parameter is a REST command. -145: * -146: * @author David Pauli <contact@david-pauli.de> +119: * @return boolean True if the string is a host, false if not. +120: * @since 0.0.0 +121: */ +122: public static function isHost($parameter) { +123: +124: return self::isMatchRegex($parameter, "/^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}/", "host") +125: && !self::isEmpty($parameter); +126: } +127: +128: /** +129: * Checks whether a parameter is an int. +130: * +131: * @author David Pauli <contact@david-pauli.de> +132: * @param int $parameter Int to check. +133: * @return boolean True if the parameter is an int, false if not. +134: * @since 0.0.0 +135: */ +136: public static function isInt($parameter) { +137: +138: return is_int($parameter) && !self::isEmpty($parameter); +139: } +140: +141: /** +142: * Checks whether a parameter is a JSON string. +143: * +144: * @author David Pauli <contact@david-pauli.de> +145: * @param String $parameter String to check. +146: * @return boolean True if the string is a JSON string, false if not. 147: * @since 0.0.0 -148: * @api -149: * @param String $parameter String to check. -150: * @return boolean True if the string is a REST command, false if not. -151: */ -152: public static function isRESTCommand($parameter) { +148: */ +149: public static function isJSON($parameter) { +150: return !is_null(json_decode($parameter)) +151: && !self::isEmpty($parameter); +152: } 153: -154: return !self::isEmpty($parameter); -155: } -156: -157: /** -158: * Checks whether a parameter is a JSON string. -159: * -160: * @author David Pauli <contact@david-pauli.de> -161: * @since 0.0.0 -162: * @api -163: * @param String $parameter String to check. -164: * @return boolean True if the string is a JSON string, false if not. -165: */ -166: public static function isJSON($parameter) { -167: return !is_null(json_decode($parameter)) -168: && !self::isEmpty($parameter); -169: } -170: -171: /** -172: * Checks whether a parameter is an int with a range. -173: * -174: * @author David Pauli <contact@david-pauli.de> -175: * @since 0.0.0 -176: * @api -177: * @param int $parameter Int to check. -178: * @param int|null $minimum The minimum allowed number, null if there is no minimum. -179: * @param int|null $maximum The maximum allowed number, null if there is no maximum. -180: * @return boolean True if the parameter is an int, false if not. -181: */ -182: public static function isRangedInt($parameter, $minimum = null, $maximum = null) { -183: -184: return self::isInt($parameter) -185: && (self::isInt($minimum) ? $parameter >= $minimum : true) -186: && (self::isInt($maximum) ? $parameter <= $maximum : true); -187: } -188: -189: /** -190: * Checks whether a parameter is a float with a range. -191: * -192: * @author David Pauli <contact@david-pauli.de> -193: * @since 0.1.0 -194: * @api -195: * @param float $parameter Float to check. -196: * @param float|null $minimum The minimum allowed number, null if there is no minimum. -197: * @param float|null $maximum The maximum allowed number, null if there is no maximum. -198: * @return boolean True if the parameter is an int, false if not. -199: */ -200: public static function isRangedFloat($parameter, $minimum = null, $maximum = null) { -201: -202: return self::isFloat($parameter) -203: && (self::isFloat($minimum) ? $parameter >= $minimum : true) -204: && (self::isFloat($maximum) ? $parameter <= $maximum : true); -205: } +154: /** +155: * Checks whether a parameter is a localization string. +156: * +157: * @author David Pauli <contact@david-pauli.de> +158: * @param String $parameter String to check. +159: * @return boolean True if the string is a localization string, false if not. +160: * @since 0.0.0 +161: */ +162: public static function isLocale($parameter) { +163: +164: return self::isMatchRegex($parameter, "/^[a-z]{2,4}_[A-Z]{2,3}$/", "Locale") +165: && !self::isEmpty($parameter); +166: } +167: +168: /** +169: * Checks whether a parameter is a log level. +170: * +171: * @author David Pauli <contact@david-pauli.de> +172: * @param String $parameter String to check. +173: * @return boolean True if the string is a log level, false if not. +174: * @since 0.0.0 +175: * @since 0.1.0 Use LogLevel enum. +176: */ +177: public static function isLogLevel($parameter) { +178: +179: return self::isMatchRegex($parameter, "/^(NOTIFICATION|WARNING|ERROR|NONE)/", "log level") +180: && !self::isEmpty($parameter); +181: } +182: +183: /** +184: * Checks whether a parameter is a product sort direction. +185: * +186: * @author David Pauli <contact@david-pauli.de> +187: * @param String $parameter String to check. +188: * @return boolean True if the parameter is a product sort direction, false if not. +189: * @since 0.0.0 +190: */ +191: public static function isProductDirection($parameter) { +192: +193: return self::isMatchRegex($parameter, "/^(asc|desc)$/", "products sort direction") +194: && !self::isEmpty($parameter); +195: } +196: +197: /** +198: * Checks whether a parameter is a valid product id. +199: * +200: * @author David Pauli <contact@david-pauli.de> +201: * @param String $parameter String to check. +202: * @return boolean True if the parameter is a valid product id, false if not. +203: * @since 0.0.0 +204: */ +205: public static function isProductId($parameter) { 206: -207: /** -208: * Checks whether a parameter is a product sort direction. -209: * -210: * @author David Pauli <contact@david-pauli.de> -211: * @since 0.0.0 -212: * @api -213: * @param String $parameter String to check. -214: * @return boolean True if the parameter is a product sort direction, false if not. -215: */ -216: public static function isProductDirection($parameter) { -217: -218: return self::isMatchRegex($parameter, "/^(asc|desc)$/", "products sort direction") -219: && !self::isEmpty($parameter); -220: } -221: -222: /** -223: * Checks whether a parameter is a product sort parameter. -224: * -225: * @author David Pauli <contact@david-pauli.de> -226: * @since 0.0.0 -227: * @api +207: return !self::isEmpty($parameter); +208: } +209: +210: /** +211: * Checks whether a parameter is a product sort parameter. +212: * +213: * @author David Pauli <contact@david-pauli.de> +214: * @param String $parameter String to check. +215: * @return boolean True if the parameter is a product sort parameter, false if not. +216: * @since 0.0.0 +217: */ +218: public static function isProductSort($parameter) { +219: +220: return self::isMatchRegex($parameter, "/^(name|price)$/", "products sort parameter") +221: && !self::isEmpty($parameter); +222: } +223: +224: /** +225: * Checks whether a parameter is an output ressource. +226: * +227: * @author David Pauli <contact@david-pauli.de> 228: * @param String $parameter String to check. -229: * @return boolean True if the parameter is a product sort parameter, false if not. -230: */ -231: public static function isProductSort($parameter) { -232: -233: return self::isMatchRegex($parameter, "/^(name|price)$/", "products sort parameter") -234: && !self::isEmpty($parameter); -235: } -236: -237: /** -238: * Checks whether a parameter is a valid product id. -239: * -240: * @author David Pauli <contact@david-pauli.de> -241: * @since 0.0.0 -242: * @api -243: * @param String $parameter String to check. -244: * @return boolean True if the parameter is a valid product id, false if not. -245: */ -246: public static function isProductId($parameter) { -247: -248: return !self::isEmpty($parameter); -249: } -250: -251: /** -252: * Checks whether a parameter is a float. -253: * -254: * @author David Pauli <contact@david-pauli.de> -255: * @since 0.1.0 -256: * @api -257: * @param float $parameter Float to check. -258: * @return boolean True if the parameter is a float, false if not. -259: */ -260: public static function isFloat($parameter) { -261: -262: return is_float($parameter) && !self::isEmpty($parameter); -263: } -264: -265: /** -266: * Checks whether a parameter is an int. -267: * -268: * @author David Pauli <contact@david-pauli.de> -269: * @since 0.0.0 -270: * @api -271: * @param int $parameter Int to check. -272: * @return boolean True if the parameter is an int, false if not. -273: */ -274: public static function isInt($parameter) { -275: -276: return is_int($parameter) && !self::isEmpty($parameter); -277: } -278: -279: /** -280: * Checks whether a parameter is an array. -281: * -282: * @author David Pauli <contact@david-pauli.de> -283: * @since 0.0.0 -284: * @api -285: * @param array $parameter Array to check. -286: * @return boolean True if the parameter is an array, false if not. -287: */ -288: public static function isArray($parameter) { -289: -290: return is_array($parameter) && !self::isEmpty($parameter); -291: } -292: -293: /** -294: * Checks whether a paramter is empty or null. -295: * -296: * @author David Pauli <contact@david-pauli.de> -297: * @since 0.0.0 -298: * @since 0.1.0 Test if the parameter is also the correct type. -299: * @api -300: * @param String $parameter String to check. -301: * @return boolean True if the parameter is empty or null, false if not. -302: */ -303: public static function isEmpty($parameter) { -304: -305: return (is_null($parameter) || ($parameter === "")); -306: } -307: -308: /** -309: * Checks whether an array is empty or null. -310: * -311: * @author David Pauli <contact@david-pauli.de> -312: * @since 0.1.0 -313: * @api -314: * @param mixed[] $parameter Array to check. -315: * @return boolean True if the array is empty or null, false if not. -316: */ -317: public static function isEmptyArray($parameter) { -318: -319: return (is_null($parameter) || empty($parameter)); -320: } -321: -322: /** -323: * Checks whether an array key is unset. -324: * -325: * @author David Pauli <contact@david-pauli.de> -326: * @since 0.1.0 -327: * @api -328: * @param mixed[] $array Array to check. -329: * @param String $key Key to exists. -330: * @return boolean True if the array key is unset, false if not. -331: */ -332: public static function isEmptyArrayKey($array, $key) { -333: -334: return self::isEmptyArray($array) || !array_key_exists($key, $array); -335: } -336: -337: /** -338: * Checks whether a parameter match a regex. -339: * -340: * @param String $parameter String to check. -341: * @param String $regex The regex to check. -342: * @param String $type The type which is validated. -343: * @return boolean True if the string validates, false if not. -344: */ -345: private static function isMatchRegex($parameter, $regex, $type) { -346: -347: if(!preg_match($regex, $parameter) && -348: !self::isEmpty($parameter)) { -349: Logger::warning("<strong>InputValidator</strong> - This is not a <u>" . $type . "</u>: <i>" . $parameter . "</i>"); -350: } -351: return preg_match($regex, $parameter); -352: } -353: -354: } -355: ?> +229: * @return boolean True if the string is an output ressource, false if not. +230: * @since 0.0.0 +231: * @since 0.1.0 Use LogOutput enum. +232: * @since 0.1.2 Add file output ressource. +233: */ +234: public static function isOutputRessource($parameter) { +235: +236: return self::isMatchRegex($parameter, "/^(SCREEN|FILE)/", "output ressource") +237: && !self::isEmpty($parameter); +238: } +239: +240: /** +241: * Checks whether a parameter is a float with a range. +242: * +243: * @author David Pauli <contact@david-pauli.de> +244: * @param float $parameter Float to check. +245: * @param float|null $minimum The minimum allowed number, null if there is no minimum. +246: * @param float|null $maximum The maximum allowed number, null if there is no maximum. +247: * @return boolean True if the parameter is an int, false if not. +248: * @since 0.1.0 +249: */ +250: public static function isRangedFloat($parameter, $minimum = null, $maximum = null) { +251: +252: return self::isFloat($parameter) +253: && (self::isFloat($minimum) ? $parameter >= $minimum : true) +254: && (self::isFloat($maximum) ? $parameter <= $maximum : true); +255: } +256: +257: /** +258: * Checks whether a parameter is an int with a range. +259: * +260: * @author David Pauli <contact@david-pauli.de> +261: * @param int $parameter Int to check. +262: * @param int|null $minimum The minimum allowed number, null if there is no minimum. +263: * @param int|null $maximum The maximum allowed number, null if there is no maximum. +264: * @return boolean True if the parameter is an int, false if not. +265: * @since 0.0.0 +266: */ +267: public static function isRangedInt($parameter, $minimum = null, $maximum = null) { +268: +269: return self::isInt($parameter) +270: && (self::isInt($minimum) ? $parameter >= $minimum : true) +271: && (self::isInt($maximum) ? $parameter <= $maximum : true); +272: } +273: +274: /** +275: * Checks whether a parameter is a REST command. +276: * +277: * @author David Pauli <contact@david-pauli.de> +278: * @param String $parameter String to check. +279: * @return boolean True if the string is a REST command, false if not. +280: * @since 0.0.0 +281: */ +282: public static function isRESTCommand($parameter) { +283: +284: return !self::isEmpty($parameter); +285: } +286: +287: /** +288: * Checks whether a parameter is a HTTP request method. +289: * +290: * @author David Pauli <contact@david-pauli.de> +291: * @param String $parameter String to check. +292: * @return boolean True if the string is a HTTP request method, false if not. +293: * @since 0.0.0 +294: * @since 0.1.0 Use HTTPRequestMethod enum. +295: */ +296: public static function isRequestMethod($parameter) { +297: +298: return self::isMatchRegex($parameter, "/^(GET|POST|PUT|DELETE|PATCH)/", "HTTP request method") +299: && !self::isEmpty($parameter); +300: } +301: +302: /** +303: * Checks whether a parameter is a shop. +304: * +305: * @author David Pauli <contact@david-pauli.de> +306: * @param String $parameter String to check. +307: * @return boolean True if the string is a shop, false if not. +308: * @since 0.0.0 +309: */ +310: public static function isShop($parameter) { +311: +312: return !self::isEmpty($parameter); +313: } +314: +315: /** +316: * Checks whether a parameter is a string. +317: * +318: * @author David Pauli <contact@david-pauli.de> +319: * @param String $parameter Parameter to check. +320: * @return boolean True if the parameter is a string, false if not. +321: * @since 0.1.2 +322: */ +323: public static function isString($parameter) { +324: +325: return is_string($parameter) && !self::isEmpty($parameter); +326: } +327: +328: /** +329: * Checks whether a parameter match a regex. +330: * +331: * @author David Pauli <contact@david-pauli.de> +332: * @param String $parameter String to check. +333: * @param String $regex The regex to check. +334: * @param String $type The type which is validated. +335: * @return boolean True if the string validates, false if not. +336: * @since 0.0.0 +337: * @since 0.1.2 Don't throw a logging message. +338: */ +339: private static function isMatchRegex($parameter, $regex, $type) { +340: +341: return preg_match($regex, $parameter); +342: } +343: +344: } +345: ?>
    - + diff --git a/doc/source-class-ep6.JSONHandler.html b/doc/source-class-ep6.JSONHandler.html index 26d2bba..2c4ea5a 100644 --- a/doc/source-class-ep6.JSONHandler.html +++ b/doc/source-class-ep6.JSONHandler.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,7 +101,7 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the JSON handler class.
    + 3:  * This file represents the JSON Handler class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
    @@ -107,62 +111,83 @@ 

    Traits

    10: * This is a small simple handler to convert JSON into an array and otherwise. 11: * 12: * @author David Pauli <contact@david-pauli.de> -13: * @since 0.0.0 -14: * @package ep6 -15: * @subpackage Util -16: */ -17: class JSONHandler { -18: /** -19: * Call this function with the JSON in parameter. -20: * -21: * @author David Pauli <contact@david-pauli.de> -22: * @since 0.0.0 -23: * @param String $JSON The JSON string to parse. -24: * @return mixed[] The array of the JSON element or null if there is an error. -25: */ -26: public static function parseJSON($JSON) { -27: -28: if (!InputValidator::isJSON($JSON)) { -29: return array(); -30: } -31: -32: $result = json_decode($JSON, true); -33: -34: if (!InputValidator::isArray($result)) { -35: Logger::warning("There is an error with parsing the follwing JSON: <strong>" . json_last_error() . ": " . json_last_error_msg() . "</strong><br/>\n" -36: . "<pre>" . $JSON . "</pre>"); -37: return array(); -38: } -39: -40: return $result; -41: } -42: -43: /** -44: * Call this function to create a JSON string from a array. -45: * -46: * @author David Pauli <contact@david-pauli.de> -47: * @since 0.0.0 -48: * @param mixed[] $array The array to make a JSON. -49: * @return String The JSON string. -50: */ -51: public static function createJSON($array) { +13: * @package ep6 +14: * @since 0.0.0 +15: * @since 0.1.2 Add error reporting. +16: * @subpackage Util +17: */ +18: class JSONHandler { +19: +20: use ErrorReporting; +21: +22: /** +23: * Call this function to create a JSON string from a array. +24: * +25: * @author David Pauli <contact@david-pauli.de> +26: * @param mixed[] $array The array to make a JSON. +27: * @return String The JSON string. +28: * @since 0.0.0 +29: * @since 0.1.2 Extend the encoding with avoid encode slashes. +30: * @since 0.1.2 Better the warnings. +31: * @since 0.1.2 Add error reporting. +32: */ +33: public static function createJSON($array) { +34: +35: self::errorReset(); +36: +37: if (!InputValidator::isArray($array)) { +38: +39: Logger::warning("ep6\JSONHandler\nArray (" . $array . ") is not valid."); +40: self::errorSet("JSONH-3"); +41: return null; +42: } +43: +44: $result = json_encode($array, JSON_UNESCAPED_SLASHES); +45: +46: if (!InputValidator::isJSON($result)) { +47: +48: Logger::warning("ep6\JSONHandler\nThere is an error with creating a JSON with the array (" . $array . "): " . json_last_error() . ": " . json_last_error_msg()); +49: self::errorSet("JSONH-4"); +50: return null; +51: } 52: -53: if (!InputValidator::isArray($array)) { -54: return null; -55: } -56: -57: $result = json_encode($array); -58: -59: if (!InputValidator::isJSON($result)) { -60: Logger::warning("There is an error with creating a JSON with the following array: <strong>" . json_last_error() . ": " . json_last_error_msg() . "</strong><br/>\n" -61: . "<pre>" . $array . "</pre>"); -62: return null; -63: } -64: -65: return $result; -66: } -67: } -68: ?>
    +53: return $result; +54: } +55: +56: /** +57: * Call this function with the JSON in parameter. +58: * +59: * @author David Pauli <contact@david-pauli.de> +60: * @param String $JSON The JSON string to parse. +61: * @return mixed[] The array of the JSON element or null if there is an error. +62: * @since 0.0.0 +63: * @since 0.1.2 Better the warnings. +64: * @since 0.1.2 Add error reporting. +65: */ +66: public static function parseJSON($JSON) { +67: +68: self::errorReset(); +69: +70: if (!InputValidator::isJSON($JSON)) { +71: +72: Logger::warning("ep6\JSONHandler\nJSON string (" . $JSON . ") is not valid."); +73: self::errorSet("JSONH-1"); +74: return array(); +75: } +76: +77: $result = json_decode($JSON, true); +78: +79: if (!InputValidator::isArray($result)) { +80: +81: Logger::warning("ep6\JSONHandler\nThere is an error with parsing the follwing JSON (" . $JSON . "): " . json_last_error() . ": " . json_last_error_msg()); +82: self::errorSet("JSONH-2"); +83: return array(); +84: } +85: +86: return $result; +87: } +88: } +89: ?>
    - + diff --git a/doc/source-class-ep6.Locales.html b/doc/source-class-ep6.Locales.html index d93d5a9..f1a285f 100644 --- a/doc/source-class-ep6.Locales.html +++ b/doc/source-class-ep6.Locales.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -107,177 +111,197 @@

    Traits

    10: * This is the static class for the localization. 11: * 12: * @author David Pauli <contact@david-pauli.de> - 13: * @since 0.0.0 - 14: * @since 0.1.0 Add a timestamp to save the next allowed REST call. - 15: * @since 0.1.0 Add configured used Locale. - 16: * @since 0.1.1 Now the object is echoable. - 17: * @package ep6 - 18: * @subpackage Shopobjects - 19: * @example examples\handleWithLocales.php Handle with locales. + 13: * @package ep6 + 14: * @since 0.0.0 + 15: * @since 0.1.0 Add a timestamp to save the next allowed REST call. + 16: * @since 0.1.0 Add configured used Locale. + 17: * @since 0.1.1 Now the object is echoable. + 18: * @since 0.1.2 Add error reporting. + 19: * @subpackage Shopobjects 20: */ 21: class Locales { 22: - 23: /** @var String The REST path for localizations. */ - 24: const RESTPATH = "locales"; - 25: - 26: /** @var String|null Space to save the default locales. */ - 27: private static $DEFAULT = null; - 28: - 29: /** @var String[] Space to save the possible locales. */ - 30: private static $ITEMS = array(); - 31: - 32: /** @var String|null Configured Locale. */ - 33: private static $USED = null; - 34: - 35: /** @var int Timestamp in ms when the next request needs to be done. */ - 36: private static $NEXT_REQUEST_TIMESTAMP = 0; - 37: - 38: /** - 39: * Gets the default and possible locales of the shop. - 40: * - 41: * @author David Pauli <contact@david-pauli.de> - 42: * @since 0.0.0 - 43: * @since 0.0.1 Use HTTPRequestMethod enum. - 44: * @since 0.1.0 Save timestamp of the last request. - 45: * @since 0.1.0 Add configured used Locale. - 46: * @api - 47: */ - 48: private static function load() { - 49: - 50: // if request method is blocked - 51: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { - 52: return; - 53: } - 54: - 55: $content = RESTClient::send(self::RESTPATH); + 23: use ErrorReporting; + 24: + 25: /** @var String The REST path for localizations. */ + 26: const RESTPATH = "locales"; + 27: + 28: /** @var String|null Space to save the default locales. */ + 29: private static $DEFAULT = null; + 30: + 31: /** @var int Timestamp in ms when the next request needs to be done. */ + 32: private static $NEXT_REQUEST_TIMESTAMP = 0; + 33: + 34: /** @var String[] Space to save the possible locales. */ + 35: private static $ITEMS = array(); + 36: + 37: /** @var String|null Configured Locale. */ + 38: private static $USED = null; + 39: + 40: /** + 41: * Gets the default localization. + 42: * + 43: * @author David Pauli <contact@david-pauli.de> + 44: * @return The default localization of the shop. + 45: * @since 0.0.0 + 46: * @since 0.1.0 Use a reload function. + 47: * @since 0.1.2 Add error reporting. + 48: */ + 49: public static function getDefault() { + 50: + 51: self::errorReset(); + 52: self::reload(); + 53: + 54: return self::$DEFAULT; + 55: } 56: - 57: // if respond is empty or there are no default AND items element - 58: if (InputValidator::isEmptyArrayKey($content, "default") || - 59: InputValidator::isEmptyArrayKey($content, "items")) { - 60: Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); - 61: return; - 62: } - 63: - 64: // reset values - 65: self::resetValues(); - 66: - 67: // save the default localization - 68: self::$DEFAULT = $content["default"]; - 69: - 70: // parse the possible localizations - 71: self::$ITEMS = $content["items"]; - 72: - 73: // set the configured shop Locale if it is empty. - 74: if (InputValidator::isEmpty(self::$USED)) { - 75: self::$USED = $content["default"]; - 76: } - 77: - 78: // update timestamp when make the next request - 79: $timestamp = (int) (microtime(true) * 1000); - 80: self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; - 81: } - 82: - 83: /** - 84: * This function resets all locales values. - 85: * - 86: * @author David Pauli <contact@david-pauli.de> - 87: * @since 0.0.0 - 88: * @since 0.1.0 Reset used Locale. - 89: * @api - 90: */ - 91: public static function resetValues() { - 92: - 93: self::$DEFAULT = null; - 94: self::$ITEMS = array(); - 95: self::$USED = null; - 96: } - 97: - 98: /** - 99: * This function checks whether a reload is needed. -100: * -101: * @author David Pauli <contact@david-pauli.de> -102: * @since 0.1.0 -103: * @api -104: */ -105: private static function reload() { + 57: /** + 58: * Gets the activated localizations. + 59: * + 60: * @author David Pauli <contact@david-pauli.de> + 61: * @return The possible localizations of the shop. + 62: * @since 0.0.0 + 63: * @since 0.1.0 Use a reload function. + 64: * @since 0.1.2 Add error reporting. + 65: */ + 66: public static function getItems() { + 67: + 68: self::errorReset(); + 69: self::reload(); + 70: + 71: return self::$ITEMS; + 72: } + 73: + 74: /** + 75: * Gets the configured Locale. + 76: * + 77: * @author David Pauli <contact@david-pauli.de> + 78: * @return The configured Locale which is used in REST calls. + 79: * @since 0.1.0 + 80: * @since 0.1.2 Add error reporting. + 81: */ + 82: public static function getLocale() { + 83: + 84: self::errorReset(); + 85: self::reload(); + 86: + 87: return self::$USED; + 88: } + 89: + 90: /** + 91: * This function resets all locales values. + 92: * + 93: * @author David Pauli <contact@david-pauli.de> + 94: * @since 0.0.0 + 95: * @since 0.1.0 Reset used Locale. + 96: * @since 0.1.2 Add error reporting. + 97: */ + 98: public static function resetValues() { + 99: +100: self::errorReset(); +101: +102: self::$DEFAULT = null; +103: self::$ITEMS = array(); +104: self::$USED = null; +105: } 106: -107: $timestamp = (int) (microtime(true) * 1000); -108: -109: // if the value is empty -110: if (!InputValidator::isEmpty(self::$DEFAULT) && -111: !InputValidator::isEmpty(self::$ITEMS) && -112: self::$NEXT_REQUEST_TIMESTAMP > $timestamp) { -113: return; -114: } -115: -116: self::load(); -117: } -118: -119: /** -120: * Gets the default localization. -121: * -122: * @author David Pauli <contact@david-pauli.de> -123: * @since 0.0.0 -124: * @since 0.1.0 Use a reload function. -125: * @api -126: * @return The default localization of the shop. -127: */ -128: public static function getDefault() { +107: /** +108: * Sets the configured Locale. +109: * +110: * @author David Pauli <contact@david-pauli.de> +111: * @param String $locale The new used Locale. +112: * @return boolean True if set the Locale works, false if not. +113: * @since 0.1.0 +114: * @since 0.1.2 Add error reporting. +115: */ +116: public static function setLocale($locale) { +117: +118: self::errorReset(); +119: self::reload(); +120: +121: if (array_key_exists($locale, self::$ITEMS)) { +122: +123: self::$USED = $locale; +124: return true; +125: } +126: +127: Logger::error("Can't set locale " . $locale . ". It is not available in the shop."); +128: self::errorSet("L-2"); 129: -130: self::reload(); -131: return self::$DEFAULT; -132: } -133: -134: /** -135: * Gets the activated localizations. -136: * -137: * @author David Pauli <contact@david-pauli.de> -138: * @since 0.0.0 -139: * @since 0.1.0 Use a reload function. -140: * @api -141: * @return The possible localizations of the shop. +130: return false; +131: } +132: +133: /** +134: * Gets the default and possible locales of the shop. +135: * +136: * @author David Pauli <contact@david-pauli.de> +137: * @since 0.0.0 +138: * @since 0.0.1 Use HTTPRequestMethod enum. +139: * @since 0.1.0 Save timestamp of the last request. +140: * @since 0.1.0 Add configured used Locale. +141: * @since 0.1.2 Add error reporting. 142: */ -143: public static function getItems() { +143: private static function load() { 144: -145: self::reload(); -146: return self::$ITEMS; -147: } -148: -149: /** -150: * Gets the configured Locale. -151: * -152: * @author David Pauli <contact@david-pauli.de> -153: * @since 0.1.0 -154: * @api -155: * @return The configured Locale which is used in REST calls. -156: */ -157: public static function getLocale() { -158: -159: self::reload(); -160: return self::$USED; -161: } -162: -163: /** -164: * Sets the configured Locale. -165: * -166: * @author David Pauli <contact@david-pauli.de> -167: * @since 0.1.0 -168: * @api -169: * @param String $locale The new used Locale. -170: * @return boolean True if set the Locale works, false if not. -171: */ -172: public static function setLocale($locale) { +145: // if request method is blocked +146: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { +147: +148: return; +149: } +150: +151: $content = RESTClient::send(self::RESTPATH); +152: +153: // if respond is empty or there are no default AND items element +154: if (InputValidator::isEmptyArrayKey($content, "default") || +155: InputValidator::isEmptyArrayKey($content, "items")) { +156: +157: Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); +158: self::errorSet("L-1"); +159: return; +160: } +161: +162: // reset values +163: self::resetValues(); +164: +165: // save the default localization +166: self::$DEFAULT = $content["default"]; +167: +168: // parse the possible localizations +169: self::$ITEMS = $content["items"]; +170: +171: // set the configured shop Locale if it is empty. +172: if (InputValidator::isEmpty(self::$USED)) { 173: -174: self::reload(); -175: if (array_key_exists($locale, self::$ITEMS)) { -176: self::$USED = $locale; -177: return true; -178: } -179: return false; +174: self::$USED = $content["default"]; +175: } +176: +177: // update timestamp when make the next request +178: $timestamp = (int) (microtime(true) * 1000); +179: self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; 180: } 181: -182: } -183: ?> +182: /** +183: * This function checks whether a reload is needed. +184: * +185: * @author David Pauli <contact@david-pauli.de> +186: * @since 0.1.0 +187: */ +188: private static function reload() { +189: +190: $timestamp = (int) (microtime(true) * 1000); +191: +192: // if the value is empty +193: if (!InputValidator::isEmpty(self::$DEFAULT) && +194: !InputValidator::isEmpty(self::$ITEMS) && +195: self::$NEXT_REQUEST_TIMESTAMP > $timestamp) { +196: +197: return; +198: } +199: +200: self::load(); +201: } +202: } +203: ?>
    - + diff --git a/doc/source-class-ep6.LogLevel.html b/doc/source-class-ep6.LogLevel.html index 375b7a3..b0c941a 100644 --- a/doc/source-class-ep6.LogLevel.html +++ b/doc/source-class-ep6.LogLevel.html @@ -4,7 +4,7 @@ - File util/Logger.class.php + File util/LogLevel.enum.php @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -95,266 +99,31 @@

    Traits

    -
      1: <?php
    -  2: /**
    -  3:  * This file represents the logger class.
    -  4:  *
    -  5:  * @author David Pauli <contact@david-pauli.de>
    -  6:  * @since 0.0.0
    -  7:  * @since 0.0.1 Add LogLevel and LogOutput classes.
    -  8:  */
    -  9: namespace ep6;
    - 10: /**
    - 11:  * This is a static object to log messages while executing.
    - 12:  *
    - 13:  * @author David Pauli <contact@david-pauli.de>
    - 14:  * @since 0.0.0
    - 15:  * @since 0.0.1 Use LogLevel and LogOutput
    - 16:  * @package ep6
    - 17:  * @subpackage Util
    - 18:  * @example examples\logMessages.php Use the Logger to log messages.
    - 19:  */
    - 20: class Logger {
    - 21: 
    - 22:     /** @var LogLevel The log level describes which error should be logged. */
    - 23:     private static $LOGLEVEL = LogLevel::NONE;
    - 24: 
    - 25:     /** @var LogOutput The output value is set to configure where logging message is made. */
    - 26:     private static $OUT = LogOutput::SCREEN;
    - 27: 
    - 28:     /**
    - 29:      * This function prints notifications.
    - 30:      *
    - 31:      * @author David Pauli <contact@david-pauli.de>
    - 32:      * @since 0.0.0
    - 33:      * @since 0.0.1 Use LogLevel
    - 34:      * @api
    - 35:      * @param String $message The message to print.
    - 36:      */
    - 37:     public static function notify($message) {
    - 38: 
    - 39:         if (InputValidator::isEmpty($message) ||
    - 40:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 41:             self::$LOGLEVEL == LogLevel::WARNING ||
    - 42:             self::$LOGLEVEL == LogLevel::NONE) {
    - 43:             return;
    - 44:         }
    - 45:         self::printMessage($message, LogLevel::NOTIFICATION);
    - 46:     }
    - 47: 
    - 48:     /**
    - 49:      * This function prints warnings.
    - 50:      *
    - 51:      * @author David Pauli <contact@david-pauli.de>
    - 52:      * @since 0.0.0
    - 53:      * @since 0.0.1 Use LogLevel
    - 54:      * @api
    - 55:      * @param String $message The message to print.
    - 56:      */
    - 57:     public static function warning($message) {
    - 58: 
    - 59:         if (InputValidator::isEmpty($message) ||
    - 60:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 61:             self::$LOGLEVEL == LogLevel::NONE) {
    - 62:             return;
    - 63:         }
    - 64:         self::printMessage($message, LogLevel::WARNING);
    - 65:     }
    - 66: 
    - 67:     /**
    - 68:      * This function prints errors.
    - 69:      *
    - 70:      * @author David Pauli <contact@david-pauli.de>
    - 71:      * @since 0.0.0
    - 72:      * @since 0.0.1 Use LogLevel
    - 73:      * @api
    - 74:      * @param String $message The message to print.
    - 75:      */
    - 76:     public static function error($message) {
    - 77: 
    - 78:         if (InputValidator::isEmpty($message) ||
    - 79:             self::$LOGLEVEL == LogLevel::NONE) {
    - 80:             return;
    - 81:         }
    - 82:         self::printMessage($message, LogLevel::ERROR);
    - 83:     }
    - 84: 
    - 85:     /**
    - 86:      * This function definitly prints the message.
    - 87:      *
    - 88:      * @author David Pauli <contact@david-pauli.de>
    - 89:      * @since 0.0.0
    - 90:      * @since 0.0.1 Use LogLevel
    - 91:      * @api
    - 92:      * @param String $message The message to print.
    - 93:      */
    - 94:     public static function force($message) {
    - 95: 
    - 96:         if (InputValidator::isEmpty($message)) {
    - 97:             return;
    - 98:         }
    - 99:         self::printMessage($message, LogLevel::FORCE);
    -100:     }
    -101: 
    -102:     /**
    -103:      * This function finally prints the message.
    -104:      *
    -105:      * @author David Pauli <contact@david-pauli.de>
    -106:      * @since 0.0.0
    -107:      * @since 0.0.1 Restructor the output message.
    -108:      * @param String $message The message to print.
    -109:      * @param LogLevel $level The message level.
    -110:      */
    -111:     private static function printMessage($message, $level) {
    -112: 
    -113:         switch (self::$OUT) {
    -114:             case LogOutput::SCREEN:
    -115:                 echo "<strong>*************** " . strtoupper($level) . " ***************</strong><pre>";
    -116: 
    -117:                 if (is_array($message)) {
    -118:                     var_dump($message);
    -119:                 }
    -120:                 else {
    -121:                     echo $message;
    -122:                 }
    -123:                 echo "</pre>";
    -124: 
    -125:                 if ($level == LogLevel::ERROR || $level == LogLevel::WARNING) {
    -126:                     self::printStacktrace();
    -127:                 }
    -128:                 break;
    -129:         }
    -130:     }
    -131: 
    -132:     /**
    -133:      * This function prints the stacktrace.
    -134:      *
    -135:      * @author David Pauli <contact@david-pauli.de>
    -136:      * @since 0.0.0
    -137:      * @since 0.0.1 Format a little bit.
    -138:      */
    -139:     private static function printStacktrace() {
    -140:         $stack = debug_backtrace();
    -141:         $messageNumber = 0;
    -142: 
    -143:         foreach ($stack as $stackentry) {
    -144:             // dont show the first 3 messages, because this are Logger functions
    -145:             if ($messageNumber < 3) {
    -146:                 $messageNumber++;
    -147:                 continue;
    -148:             }
    -149:             echo "<pre>Function <strong>" . $stackentry['function'] . "</strong>( ";
    -150:             var_dump($stackentry['args']);
    -151:             echo " ) called at <strong>" . $stackentry["file"] . "</strong> line " . $stackentry["line"] . "</pre>";
    -152:         }
    -153:     }
    -154: 
    -155:     /**
    -156:      * This function sets the log level.
    -157:      *
    -158:      * @author David Pauli <contact@david-pauli.de>
    -159:      * @since 0.0.0
    -160:      * @since 0.0.1 Use LogLevel enum.
    -161:      * @since 0.0.3 Set php error reporting automatically in developing systems.
    -162:      * @api
    -163:      * @param LogLevel $level The log level to set.
    -164:      */
    -165:     public static function setLogLevel($level) {
    -166:         if (!InputValidator::isLogLevel($level)) {
    -167:             return;
    -168:         }
    -169: 
    -170:         // set PHP error reporting
    -171:         switch ($level) {
    -172:             case LogLevel::ERROR:
    -173:                 error_reporting(E_ERROR);
    -174:                 ini_set("display_errors", 1);
    -175:                 break;
    -176:             case LogLevel::NOTIFICATION:
    -177:                 error_reporting(E_ALL);
    -178:                 ini_set("display_errors", 1);
    -179:                 break;
    -180:             case LogLevel::WARNING:
    -181:                 error_reporting(E_WARNING);
    -182:                 ini_set("display_errors", 1);
    -183:                 break;
    -184:             default:
    -185:                 ini_set("display_errors", 0);
    -186:         }
    -187:         self::$LOGLEVEL = $level;
    -188:     }
    -189: 
    -190:     /**
    -191:      * This function sets the output ressource.
    -192:      *
    -193:      * @author David Pauli <contact@david-pauli.de>
    -194:      * @since 0.0.0
    -195:      * @since 0.0.1 Use LogOutput enum.
    -196:      * @api
    -197:      * @param LogOutput $out The resource to output.
    -198:      */
    -199:     public static function setOutput($out) {
    -200:         if (!InputValidator::isOutputRessource($out)) {
    -201:             return;
    -202:         }
    -203:         self::$OUT = $out;
    -204:     }
    -205: 
    -206:     /**
    -207:      * Prints the Logger object as a string.
    -208:      *
    -209:      * This function returns the setted values of the Logger object.
    -210:      *
    -211:      * @author David Pauli <contact@david-pauli.de>
    -212:      * @since 0.1.1
    -213:      * @return String The Logger as a string.
    -214:      */
    -215:     public function __toString() {
    -216: 
    -217:         return "<strong>Log level:</strong> " . self::$LOGLEVEL . "<br/>" .
    -218:                 "<strong>Output resource:</strong> " . self::$OUT . "<br/>";
    -219:     }
    -220: }
    -221: 
    -222: /**
    -223:  * The log level 'enum'.
    -224:  *
    -225:  * Use this to define which log messages should be printed.
    -226:  *
    -227:  * @author David Pauli <contact@david-pauli.de>
    -228:  * @since 0.0.1
    -229:  * @package ep6
    -230:  * @subpackage Util\Logger
    -231:  */
    -232: abstract class LogLevel {
    -233:     /** @var String Use this to print all messages. **/
    -234:     const NOTIFICATION = "NOTIFICATION";
    -235:     /** @var String Use this to print only warnings and errors. **/
    -236:     const WARNING = "WARNING";
    -237:     /** @var String Use this to print only errors. **/
    -238:     const ERROR = "ERROR";
    -239:     /** @var String Use this to print no log messages. **/
    -240:     const NONE = "NONE";
    -241:     /** @var String This is only used for intern reasons. **/
    -242:     const FORCE = "FORCE";
    -243: }
    -244: 
    -245: /**
    -246:  * The log output 'enum'.
    -247:  *
    -248:  * Use this to define where the log messages should be printed.
    -249:  *
    -250:  * @author David Pauli <contact@david-pauli.de>
    -251:  * @since 0.0.1
    -252:  * @package ep6
    -253:  * @subpackage Util\Logger
    -254:  */
    -255: abstract class LogOutput {
    -256:     /** @var String Use this for print something on the screen. **/
    -257:     const SCREEN = "SCREEN";
    -258: }
    -259: 
    -260: ?>
    +
     1: <?php
    + 2: namespace ep6;
    + 3: /**
    + 4:  * The Log Level 'enum'.
    + 5:  *
    + 6:  * Use this to define which log messages should be printed.
    + 7:  *
    + 8:  * @author David Pauli <contact@david-pauli.de>
    + 9:  * @package ep6
    +10:  * @since 0.0.1
    +11:  * @subpackage Util\Logger
    +12:  */
    +13: abstract class LogLevel {
    +14:     /** @var String Use this to print all messages. **/
    +15:     const NOTIFICATION = "NOTIFICATION";
    +16:     /** @var String Use this to print only warnings and errors. **/
    +17:     const WARNING = "WARNING";
    +18:     /** @var String Use this to print only errors. **/
    +19:     const ERROR = "ERROR";
    +20:     /** @var String Use this to print no log messages. **/
    +21:     const NONE = "NONE";
    +22:     /** @var String This is only used for intern reasons. **/
    +23:     const FORCE = "FORCE";
    +24: }
    +25: ?>
    - + diff --git a/doc/source-class-ep6.LogOutput.html b/doc/source-class-ep6.LogOutput.html index 375b7a3..5f40495 100644 --- a/doc/source-class-ep6.LogOutput.html +++ b/doc/source-class-ep6.LogOutput.html @@ -4,7 +4,7 @@ - File util/Logger.class.php + File util/LogOutput.enum.php @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -95,266 +99,26 @@

    Traits

    -
      1: <?php
    -  2: /**
    -  3:  * This file represents the logger class.
    -  4:  *
    -  5:  * @author David Pauli <contact@david-pauli.de>
    -  6:  * @since 0.0.0
    -  7:  * @since 0.0.1 Add LogLevel and LogOutput classes.
    -  8:  */
    -  9: namespace ep6;
    - 10: /**
    - 11:  * This is a static object to log messages while executing.
    - 12:  *
    - 13:  * @author David Pauli <contact@david-pauli.de>
    - 14:  * @since 0.0.0
    - 15:  * @since 0.0.1 Use LogLevel and LogOutput
    - 16:  * @package ep6
    - 17:  * @subpackage Util
    - 18:  * @example examples\logMessages.php Use the Logger to log messages.
    - 19:  */
    - 20: class Logger {
    - 21: 
    - 22:     /** @var LogLevel The log level describes which error should be logged. */
    - 23:     private static $LOGLEVEL = LogLevel::NONE;
    - 24: 
    - 25:     /** @var LogOutput The output value is set to configure where logging message is made. */
    - 26:     private static $OUT = LogOutput::SCREEN;
    - 27: 
    - 28:     /**
    - 29:      * This function prints notifications.
    - 30:      *
    - 31:      * @author David Pauli <contact@david-pauli.de>
    - 32:      * @since 0.0.0
    - 33:      * @since 0.0.1 Use LogLevel
    - 34:      * @api
    - 35:      * @param String $message The message to print.
    - 36:      */
    - 37:     public static function notify($message) {
    - 38: 
    - 39:         if (InputValidator::isEmpty($message) ||
    - 40:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 41:             self::$LOGLEVEL == LogLevel::WARNING ||
    - 42:             self::$LOGLEVEL == LogLevel::NONE) {
    - 43:             return;
    - 44:         }
    - 45:         self::printMessage($message, LogLevel::NOTIFICATION);
    - 46:     }
    - 47: 
    - 48:     /**
    - 49:      * This function prints warnings.
    - 50:      *
    - 51:      * @author David Pauli <contact@david-pauli.de>
    - 52:      * @since 0.0.0
    - 53:      * @since 0.0.1 Use LogLevel
    - 54:      * @api
    - 55:      * @param String $message The message to print.
    - 56:      */
    - 57:     public static function warning($message) {
    - 58: 
    - 59:         if (InputValidator::isEmpty($message) ||
    - 60:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 61:             self::$LOGLEVEL == LogLevel::NONE) {
    - 62:             return;
    - 63:         }
    - 64:         self::printMessage($message, LogLevel::WARNING);
    - 65:     }
    - 66: 
    - 67:     /**
    - 68:      * This function prints errors.
    - 69:      *
    - 70:      * @author David Pauli <contact@david-pauli.de>
    - 71:      * @since 0.0.0
    - 72:      * @since 0.0.1 Use LogLevel
    - 73:      * @api
    - 74:      * @param String $message The message to print.
    - 75:      */
    - 76:     public static function error($message) {
    - 77: 
    - 78:         if (InputValidator::isEmpty($message) ||
    - 79:             self::$LOGLEVEL == LogLevel::NONE) {
    - 80:             return;
    - 81:         }
    - 82:         self::printMessage($message, LogLevel::ERROR);
    - 83:     }
    - 84: 
    - 85:     /**
    - 86:      * This function definitly prints the message.
    - 87:      *
    - 88:      * @author David Pauli <contact@david-pauli.de>
    - 89:      * @since 0.0.0
    - 90:      * @since 0.0.1 Use LogLevel
    - 91:      * @api
    - 92:      * @param String $message The message to print.
    - 93:      */
    - 94:     public static function force($message) {
    - 95: 
    - 96:         if (InputValidator::isEmpty($message)) {
    - 97:             return;
    - 98:         }
    - 99:         self::printMessage($message, LogLevel::FORCE);
    -100:     }
    -101: 
    -102:     /**
    -103:      * This function finally prints the message.
    -104:      *
    -105:      * @author David Pauli <contact@david-pauli.de>
    -106:      * @since 0.0.0
    -107:      * @since 0.0.1 Restructor the output message.
    -108:      * @param String $message The message to print.
    -109:      * @param LogLevel $level The message level.
    -110:      */
    -111:     private static function printMessage($message, $level) {
    -112: 
    -113:         switch (self::$OUT) {
    -114:             case LogOutput::SCREEN:
    -115:                 echo "<strong>*************** " . strtoupper($level) . " ***************</strong><pre>";
    -116: 
    -117:                 if (is_array($message)) {
    -118:                     var_dump($message);
    -119:                 }
    -120:                 else {
    -121:                     echo $message;
    -122:                 }
    -123:                 echo "</pre>";
    -124: 
    -125:                 if ($level == LogLevel::ERROR || $level == LogLevel::WARNING) {
    -126:                     self::printStacktrace();
    -127:                 }
    -128:                 break;
    -129:         }
    -130:     }
    -131: 
    -132:     /**
    -133:      * This function prints the stacktrace.
    -134:      *
    -135:      * @author David Pauli <contact@david-pauli.de>
    -136:      * @since 0.0.0
    -137:      * @since 0.0.1 Format a little bit.
    -138:      */
    -139:     private static function printStacktrace() {
    -140:         $stack = debug_backtrace();
    -141:         $messageNumber = 0;
    -142: 
    -143:         foreach ($stack as $stackentry) {
    -144:             // dont show the first 3 messages, because this are Logger functions
    -145:             if ($messageNumber < 3) {
    -146:                 $messageNumber++;
    -147:                 continue;
    -148:             }
    -149:             echo "<pre>Function <strong>" . $stackentry['function'] . "</strong>( ";
    -150:             var_dump($stackentry['args']);
    -151:             echo " ) called at <strong>" . $stackentry["file"] . "</strong> line " . $stackentry["line"] . "</pre>";
    -152:         }
    -153:     }
    -154: 
    -155:     /**
    -156:      * This function sets the log level.
    -157:      *
    -158:      * @author David Pauli <contact@david-pauli.de>
    -159:      * @since 0.0.0
    -160:      * @since 0.0.1 Use LogLevel enum.
    -161:      * @since 0.0.3 Set php error reporting automatically in developing systems.
    -162:      * @api
    -163:      * @param LogLevel $level The log level to set.
    -164:      */
    -165:     public static function setLogLevel($level) {
    -166:         if (!InputValidator::isLogLevel($level)) {
    -167:             return;
    -168:         }
    -169: 
    -170:         // set PHP error reporting
    -171:         switch ($level) {
    -172:             case LogLevel::ERROR:
    -173:                 error_reporting(E_ERROR);
    -174:                 ini_set("display_errors", 1);
    -175:                 break;
    -176:             case LogLevel::NOTIFICATION:
    -177:                 error_reporting(E_ALL);
    -178:                 ini_set("display_errors", 1);
    -179:                 break;
    -180:             case LogLevel::WARNING:
    -181:                 error_reporting(E_WARNING);
    -182:                 ini_set("display_errors", 1);
    -183:                 break;
    -184:             default:
    -185:                 ini_set("display_errors", 0);
    -186:         }
    -187:         self::$LOGLEVEL = $level;
    -188:     }
    -189: 
    -190:     /**
    -191:      * This function sets the output ressource.
    -192:      *
    -193:      * @author David Pauli <contact@david-pauli.de>
    -194:      * @since 0.0.0
    -195:      * @since 0.0.1 Use LogOutput enum.
    -196:      * @api
    -197:      * @param LogOutput $out The resource to output.
    -198:      */
    -199:     public static function setOutput($out) {
    -200:         if (!InputValidator::isOutputRessource($out)) {
    -201:             return;
    -202:         }
    -203:         self::$OUT = $out;
    -204:     }
    -205: 
    -206:     /**
    -207:      * Prints the Logger object as a string.
    -208:      *
    -209:      * This function returns the setted values of the Logger object.
    -210:      *
    -211:      * @author David Pauli <contact@david-pauli.de>
    -212:      * @since 0.1.1
    -213:      * @return String The Logger as a string.
    -214:      */
    -215:     public function __toString() {
    -216: 
    -217:         return "<strong>Log level:</strong> " . self::$LOGLEVEL . "<br/>" .
    -218:                 "<strong>Output resource:</strong> " . self::$OUT . "<br/>";
    -219:     }
    -220: }
    -221: 
    -222: /**
    -223:  * The log level 'enum'.
    -224:  *
    -225:  * Use this to define which log messages should be printed.
    -226:  *
    -227:  * @author David Pauli <contact@david-pauli.de>
    -228:  * @since 0.0.1
    -229:  * @package ep6
    -230:  * @subpackage Util\Logger
    -231:  */
    -232: abstract class LogLevel {
    -233:     /** @var String Use this to print all messages. **/
    -234:     const NOTIFICATION = "NOTIFICATION";
    -235:     /** @var String Use this to print only warnings and errors. **/
    -236:     const WARNING = "WARNING";
    -237:     /** @var String Use this to print only errors. **/
    -238:     const ERROR = "ERROR";
    -239:     /** @var String Use this to print no log messages. **/
    -240:     const NONE = "NONE";
    -241:     /** @var String This is only used for intern reasons. **/
    -242:     const FORCE = "FORCE";
    -243: }
    -244: 
    -245: /**
    -246:  * The log output 'enum'.
    -247:  *
    -248:  * Use this to define where the log messages should be printed.
    -249:  *
    -250:  * @author David Pauli <contact@david-pauli.de>
    -251:  * @since 0.0.1
    -252:  * @package ep6
    -253:  * @subpackage Util\Logger
    -254:  */
    -255: abstract class LogOutput {
    -256:     /** @var String Use this for print something on the screen. **/
    -257:     const SCREEN = "SCREEN";
    -258: }
    -259: 
    -260: ?>
    +
     1: <?php
    + 2: namespace ep6;
    + 3: /**
    + 4:  * The Log Output 'enum'.
    + 5:  *
    + 6:  * Use this to define where the log messages should be printed.
    + 7:  *
    + 8:  * @author David Pauli <contact@david-pauli.de>
    + 9:  * @package ep6
    +10:  * @since 0.0.1
    +11:  * @since 0.1.2
    +12:  * @subpackage Util\Logger
    +13:  */
    +14: abstract class LogOutput {
    +15:     /** @var String Use this for print something on the screen. **/
    +16:     const SCREEN = "SCREEN";
    +17:     /** @var String Use this for print something on the screen. **/
    +18:     const FILE = "FILE";
    +19: }
    +20: ?>
    - + diff --git a/doc/source-class-ep6.Logger.html b/doc/source-class-ep6.Logger.html index 375b7a3..434dceb 100644 --- a/doc/source-class-ep6.Logger.html +++ b/doc/source-class-ep6.Logger.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,264 +101,267 @@

    Traits

      1: <?php
       2: /**
    -  3:  * This file represents the logger class.
    +  3:  * This file represents the Logger class.
       4:  *
       5:  * @author David Pauli <contact@david-pauli.de>
       6:  * @since 0.0.0
       7:  * @since 0.0.1 Add LogLevel and LogOutput classes.
    -  8:  */
    -  9: namespace ep6;
    - 10: /**
    - 11:  * This is a static object to log messages while executing.
    - 12:  *
    - 13:  * @author David Pauli <contact@david-pauli.de>
    - 14:  * @since 0.0.0
    - 15:  * @since 0.0.1 Use LogLevel and LogOutput
    - 16:  * @package ep6
    - 17:  * @subpackage Util
    - 18:  * @example examples\logMessages.php Use the Logger to log messages.
    - 19:  */
    - 20: class Logger {
    - 21: 
    - 22:     /** @var LogLevel The log level describes which error should be logged. */
    - 23:     private static $LOGLEVEL = LogLevel::NONE;
    - 24: 
    - 25:     /** @var LogOutput The output value is set to configure where logging message is made. */
    - 26:     private static $OUT = LogOutput::SCREEN;
    - 27: 
    - 28:     /**
    - 29:      * This function prints notifications.
    - 30:      *
    - 31:      * @author David Pauli <contact@david-pauli.de>
    - 32:      * @since 0.0.0
    - 33:      * @since 0.0.1 Use LogLevel
    - 34:      * @api
    - 35:      * @param String $message The message to print.
    - 36:      */
    - 37:     public static function notify($message) {
    - 38: 
    - 39:         if (InputValidator::isEmpty($message) ||
    - 40:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 41:             self::$LOGLEVEL == LogLevel::WARNING ||
    - 42:             self::$LOGLEVEL == LogLevel::NONE) {
    - 43:             return;
    - 44:         }
    - 45:         self::printMessage($message, LogLevel::NOTIFICATION);
    - 46:     }
    - 47: 
    - 48:     /**
    - 49:      * This function prints warnings.
    - 50:      *
    - 51:      * @author David Pauli <contact@david-pauli.de>
    +  8:  * @since 0.1.2 Move LogLevel and LogOutput enum to own files.
    +  9:  */
    + 10: namespace ep6;
    + 11: /**
    + 12:  * This is a static object to log messages while executing.
    + 13:  *
    + 14:  * @author David Pauli <contact@david-pauli.de>
    + 15:  * @package ep6
    + 16:  * @since 0.0.0
    + 17:  * @since 0.0.1 Use LogLevel and LogOutput
    + 18:  * @since 0.1.2 Add functionality to print into files.
    + 19:  * @subpackage Util
    + 20:  */
    + 21: class Logger {
    + 22: 
    + 23:     /** @var LogLevel The log level describes which error should be logged. */
    + 24:     private static $LOGLEVEL = LogLevel::NONE;
    + 25: 
    + 26:     /** @var LogOutput The output value is set to configure where logging message is made. */
    + 27:     private static $OUT = LogOutput::SCREEN;
    + 28: 
    + 29:     /** @var String The default output file for printing log messages. */
    + 30:     private static $OUTPUT_FILE;
    + 31: 
    + 32:     /**
    + 33:      * Prints the Logger object as a string.
    + 34:      *
    + 35:      * This function returns the setted values of the Logger object.
    + 36:      *
    + 37:      * @author David Pauli <contact@david-pauli.de>
    + 38:      * @return String The Logger as a string.
    + 39:      * @since 0.1.1
    + 40:      */
    + 41:     public function __toString() {
    + 42: 
    + 43:         return "<strong>Log level:</strong> " . self::$LOGLEVEL . "<br/>" .
    + 44:                 "<strong>Output resource:</strong> " . self::$OUT . "<br/>";
    + 45:     }
    + 46: 
    + 47:     /**
    + 48:      * This function prints errors.
    + 49:      *
    + 50:      * @author David Pauli <contact@david-pauli.de>
    + 51:      * @param String $message The message to print.
      52:      * @since 0.0.0
      53:      * @since 0.0.1 Use LogLevel
    - 54:      * @api
    - 55:      * @param String $message The message to print.
    - 56:      */
    - 57:     public static function warning($message) {
    - 58: 
    - 59:         if (InputValidator::isEmpty($message) ||
    - 60:             self::$LOGLEVEL == LogLevel::ERROR ||
    - 61:             self::$LOGLEVEL == LogLevel::NONE) {
    - 62:             return;
    - 63:         }
    - 64:         self::printMessage($message, LogLevel::WARNING);
    + 54:      * @since 0.1.2 Call the printMessage function on another way.
    + 55:      */
    + 56:     public static function error($message) {
    + 57: 
    + 58:         if (InputValidator::isEmpty($message) ||
    + 59:             self::$LOGLEVEL == LogLevel::NONE) {
    + 60: 
    + 61:             return;
    + 62:         }
    + 63: 
    + 64:         self::printMessage($message, true);
      65:     }
      66: 
      67:     /**
    - 68:      * This function prints errors.
    + 68:      * This function definitly prints the message.
      69:      *
      70:      * @author David Pauli <contact@david-pauli.de>
    - 71:      * @since 0.0.0
    - 72:      * @since 0.0.1 Use LogLevel
    - 73:      * @api
    - 74:      * @param String $message The message to print.
    + 71:      * @param String $message The message to print.
    + 72:      * @since 0.0.0
    + 73:      * @since 0.0.1 Use LogLevel
    + 74:      * @since 0.1.2 Call the printMessage function on another way.
      75:      */
    - 76:     public static function error($message) {
    + 76:     public static function force($message) {
      77: 
    - 78:         if (InputValidator::isEmpty($message) ||
    - 79:             self::$LOGLEVEL == LogLevel::NONE) {
    + 78:         if (InputValidator::isEmpty($message)) {
    + 79: 
      80:             return;
      81:         }
    - 82:         self::printMessage($message, LogLevel::ERROR);
    - 83:     }
    - 84: 
    - 85:     /**
    - 86:      * This function definitly prints the message.
    - 87:      *
    - 88:      * @author David Pauli <contact@david-pauli.de>
    - 89:      * @since 0.0.0
    - 90:      * @since 0.0.1 Use LogLevel
    - 91:      * @api
    - 92:      * @param String $message The message to print.
    - 93:      */
    - 94:     public static function force($message) {
    - 95: 
    - 96:         if (InputValidator::isEmpty($message)) {
    - 97:             return;
    - 98:         }
    - 99:         self::printMessage($message, LogLevel::FORCE);
    -100:     }
    + 82: 
    + 83:         self::printMessage($message);
    + 84:     }
    + 85: 
    + 86:     /**
    + 87:      * This function prints notifications.
    + 88:      *
    + 89:      * @author David Pauli <contact@david-pauli.de>
    + 90:      * @param String $message The message to print.
    + 91:      * @since 0.0.0
    + 92:      * @since 0.0.1 Use LogLevel
    + 93:      * @since 0.1.2 Call the printMessage function on another way.
    + 94:      */
    + 95:     public static function notify($message) {
    + 96: 
    + 97:         if (InputValidator::isEmpty($message) ||
    + 98:             self::$LOGLEVEL == LogLevel::ERROR ||
    + 99:             self::$LOGLEVEL == LogLevel::WARNING ||
    +100:             self::$LOGLEVEL == LogLevel::NONE) {
     101: 
    -102:     /**
    -103:      * This function finally prints the message.
    -104:      *
    -105:      * @author David Pauli <contact@david-pauli.de>
    -106:      * @since 0.0.0
    -107:      * @since 0.0.1 Restructor the output message.
    -108:      * @param String $message The message to print.
    -109:      * @param LogLevel $level The message level.
    -110:      */
    -111:     private static function printMessage($message, $level) {
    -112: 
    -113:         switch (self::$OUT) {
    -114:             case LogOutput::SCREEN:
    -115:                 echo "<strong>*************** " . strtoupper($level) . " ***************</strong><pre>";
    -116: 
    -117:                 if (is_array($message)) {
    -118:                     var_dump($message);
    -119:                 }
    -120:                 else {
    -121:                     echo $message;
    -122:                 }
    -123:                 echo "</pre>";
    +102:             return;
    +103:         }
    +104: 
    +105:         self::printMessage($message);
    +106:     }
    +107: 
    +108:     /**
    +109:      * This function sets the log level.
    +110:      *
    +111:      * @author David Pauli <contact@david-pauli.de>
    +112:      * @param LogLevel $level The log level to set.
    +113:      * @since 0.0.0
    +114:      * @since 0.0.1 Use LogLevel enum.
    +115:      * @since 0.0.3 Set php error reporting automatically in developing systems.
    +116:      * @since 0.1.2 epages-rest-php log level will not take effect in PHP log level.
    +117:      */
    +118:     public static function setLogLevel($level) {
    +119: 
    +120:         if (!InputValidator::isLogLevel($level)) {
    +121: 
    +122:             return;
    +123:         }
     124: 
    -125:                 if ($level == LogLevel::ERROR || $level == LogLevel::WARNING) {
    -126:                     self::printStacktrace();
    -127:                 }
    -128:                 break;
    -129:         }
    -130:     }
    -131: 
    -132:     /**
    -133:      * This function prints the stacktrace.
    -134:      *
    -135:      * @author David Pauli <contact@david-pauli.de>
    -136:      * @since 0.0.0
    -137:      * @since 0.0.1 Format a little bit.
    -138:      */
    -139:     private static function printStacktrace() {
    -140:         $stack = debug_backtrace();
    -141:         $messageNumber = 0;
    +125:         self::$LOGLEVEL = $level;
    +126:     }
    +127: 
    +128:     /**
    +129:      * This function sets the output ressource.
    +130:      *
    +131:      * @author David Pauli <contact@david-pauli.de>
    +132:      * @param LogOutput $out The resource to output.
    +133:      * @since 0.0.0
    +134:      * @since 0.0.1 Use LogOutput enum.
    +135:      */
    +136:     public static function setOutput($out) {
    +137: 
    +138:         if (!InputValidator::isOutputRessource($out)) {
    +139: 
    +140:             return;
    +141:         }
     142: 
    -143:         foreach ($stack as $stackentry) {
    -144:             // dont show the first 3 messages, because this are Logger functions
    -145:             if ($messageNumber < 3) {
    -146:                 $messageNumber++;
    -147:                 continue;
    -148:             }
    -149:             echo "<pre>Function <strong>" . $stackentry['function'] . "</strong>( ";
    -150:             var_dump($stackentry['args']);
    -151:             echo " ) called at <strong>" . $stackentry["file"] . "</strong> line " . $stackentry["line"] . "</pre>";
    -152:         }
    -153:     }
    +143:         self::$OUT = $out;
    +144:     }
    +145: 
    +146:     /**
    +147:      * This function sets the output file.
    +148:      *
    +149:      * @author David Pauli <contact@david-pauli.de>
    +150:      * @param String $filename The filename of the new output file with path on the server.
    +151:      * @since 0.1.2
    +152:      */
    +153:     public static function setOutputFile($filename) {
     154: 
    -155:     /**
    -156:      * This function sets the log level.
    -157:      *
    -158:      * @author David Pauli <contact@david-pauli.de>
    -159:      * @since 0.0.0
    -160:      * @since 0.0.1 Use LogLevel enum.
    -161:      * @since 0.0.3 Set php error reporting automatically in developing systems.
    -162:      * @api
    -163:      * @param LogLevel $level The log level to set.
    -164:      */
    -165:     public static function setLogLevel($level) {
    -166:         if (!InputValidator::isLogLevel($level)) {
    -167:             return;
    -168:         }
    -169: 
    -170:         // set PHP error reporting
    -171:         switch ($level) {
    -172:             case LogLevel::ERROR:
    -173:                 error_reporting(E_ERROR);
    -174:                 ini_set("display_errors", 1);
    -175:                 break;
    -176:             case LogLevel::NOTIFICATION:
    -177:                 error_reporting(E_ALL);
    -178:                 ini_set("display_errors", 1);
    -179:                 break;
    -180:             case LogLevel::WARNING:
    -181:                 error_reporting(E_WARNING);
    -182:                 ini_set("display_errors", 1);
    -183:                 break;
    -184:             default:
    -185:                 ini_set("display_errors", 0);
    -186:         }
    -187:         self::$LOGLEVEL = $level;
    -188:     }
    -189: 
    -190:     /**
    -191:      * This function sets the output ressource.
    -192:      *
    -193:      * @author David Pauli <contact@david-pauli.de>
    -194:      * @since 0.0.0
    -195:      * @since 0.0.1 Use LogOutput enum.
    -196:      * @api
    -197:      * @param LogOutput $out The resource to output.
    -198:      */
    -199:     public static function setOutput($out) {
    -200:         if (!InputValidator::isOutputRessource($out)) {
    -201:             return;
    -202:         }
    -203:         self::$OUT = $out;
    -204:     }
    -205: 
    -206:     /**
    -207:      * Prints the Logger object as a string.
    -208:      *
    -209:      * This function returns the setted values of the Logger object.
    -210:      *
    -211:      * @author David Pauli <contact@david-pauli.de>
    -212:      * @since 0.1.1
    -213:      * @return String The Logger as a string.
    -214:      */
    -215:     public function __toString() {
    -216: 
    -217:         return "<strong>Log level:</strong> " . self::$LOGLEVEL . "<br/>" .
    -218:                 "<strong>Output resource:</strong> " . self::$OUT . "<br/>";
    -219:     }
    -220: }
    -221: 
    -222: /**
    -223:  * The log level 'enum'.
    -224:  *
    -225:  * Use this to define which log messages should be printed.
    -226:  *
    -227:  * @author David Pauli <contact@david-pauli.de>
    -228:  * @since 0.0.1
    -229:  * @package ep6
    -230:  * @subpackage Util\Logger
    -231:  */
    -232: abstract class LogLevel {
    -233:     /** @var String Use this to print all messages. **/
    -234:     const NOTIFICATION = "NOTIFICATION";
    -235:     /** @var String Use this to print only warnings and errors. **/
    -236:     const WARNING = "WARNING";
    -237:     /** @var String Use this to print only errors. **/
    -238:     const ERROR = "ERROR";
    -239:     /** @var String Use this to print no log messages. **/
    -240:     const NONE = "NONE";
    -241:     /** @var String This is only used for intern reasons. **/
    -242:     const FORCE = "FORCE";
    -243: }
    -244: 
    -245: /**
    -246:  * The log output 'enum'.
    -247:  *
    -248:  * Use this to define where the log messages should be printed.
    -249:  *
    -250:  * @author David Pauli <contact@david-pauli.de>
    -251:  * @since 0.0.1
    -252:  * @package ep6
    -253:  * @subpackage Util\Logger
    -254:  */
    -255: abstract class LogOutput {
    -256:     /** @var String Use this for print something on the screen. **/
    -257:     const SCREEN = "SCREEN";
    -258: }
    -259: 
    -260: ?>
    +155: if (InputValidator::isEmpty($filename)) { +156: +157: return; +158: } +159: +160: self::$OUTPUT_FILE = $filename; +161: } +162: +163: /** +164: * This function prints warnings. +165: * +166: * @author David Pauli <contact@david-pauli.de> +167: * @param String $message The message to print. +168: * @since 0.0.0 +169: * @since 0.0.1 Use LogLevel +170: * @since 0.1.2 Call the printMessage function on another way. +171: */ +172: public static function warning($message) { +173: +174: if (InputValidator::isEmpty($message) || +175: self::$LOGLEVEL == LogLevel::ERROR || +176: self::$LOGLEVEL == LogLevel::NONE) { +177: +178: return; +179: } +180: +181: self::printMessage($message, true); +182: } +183: +184: /** +185: * This function returns the stacktrace. +186: * +187: * @author David Pauli <contact@david-pauli.de> +188: * @return String The Stacktrace. +189: * @since 0.1.2 +190: */ +191: private static function getStacktrace() { +192: +193: $stack = debug_backtrace(); +194: $messageNumber = 0; +195: $stacktrace = ""; +196: +197: foreach ($stack as $stackentry) { +198: // dont show the first 3 messages, because this are intern Logger functions +199: if ($messageNumber < 3) { +200: +201: $messageNumber++; +202: continue; +203: } +204: +205: $stacktrace .= "function " . $stackentry['function'] . "("; +206: $stacktrace .= implode(",", $stackentry['args']); +207: $stacktrace .= ") called at " . $stackentry["file"] . " line " . $stackentry["line"]; +208: $stacktrace .= "\n"; +209: } +210: +211: return $stacktrace; +212: } +213: +214: /** +215: * This function finally prints the message. +216: * +217: * @author David Pauli <contact@david-pauli.de> +218: * @param String $message The message to print. +219: * @param boolean $showStacktrace = 'false' True if a stacktrace show be shown, false if not. +220: * @since 0.0.0 +221: * @since 0.0.1 Restructor the output message. +222: * @since 0.1.2 Restructure log message and print to file. +223: */ +224: private static function printMessage($message, $showStacktrace = false) { +225: +226: // build output +227: $output = $_SERVER['REMOTE_ADDR'] . " - "; +228: $output .= "[" . date("d/M/Y:H:i:s O") . "] "; +229: +230: // print message, if it is array or string +231: if (is_array($message)) { +232: +233: $output .= "\n" . implode(",", $message); +234: } +235: else { +236: +237: $output .= "\n" . $message; +238: } +239: +240: // print stacktrace if its needed +241: if ($showStacktrace) { +242: +243: $output .= "\nStacktrace:\n" . self::getStacktrace(); +244: } +245: +246: switch (self::$OUT) { +247: +248: case LogOutput::SCREEN: +249: echo "<pre>"; +250: echo $output; +251: echo "</pre>"; +252: break; +253: +254: case LogOutput::FILE: +255: $handle = fopen(self::$OUTPUT_FILE, "a"); +256: fwrite($handle, $output); +257: fwrite($handle, "\n===\n\n"); +258: fclose($handle); +259: break; +260: } +261: } +262: } +263: ?>
    - + diff --git a/doc/source-class-ep6.Price.html b/doc/source-class-ep6.Price.html index 4063a98..5170575 100644 --- a/doc/source-class-ep6.Price.html +++ b/doc/source-class-ep6.Price.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,21 +101,21 @@

    Traits

      1: <?php
       2: /**
    -  3:  * This file represents the price class.
    +  3:  * This file represents the Price class.
       4:  *
       5:  * @author David Pauli <contact@david-pauli.de>
       6:  * @since 0.0.0
       7:  */
       8: namespace ep6;
       9: /**
    - 10:  * This is the class for price objects.
    + 10:  * This is the class for Price objects.
      11:  *
      12:  * @author David Pauli <contact@david-pauli.de>
    - 13:  * @since 0.0.0
    - 14:  * @since 0.1.1 This object is echoable.
    - 15:  * @since 0.1.1 Set attribute to protected to use it in the child classes.
    - 16:  * @since 0.1.1 Add formatted attribute.
    - 17:  * @package ep6
    + 13:  * @package ep6
    + 14:  * @since 0.0.0
    + 15:  * @since 0.1.1 This object is echoable.
    + 16:  * @since 0.1.1 Set attribute to protected to use it in the child classes.
    + 17:  * @since 0.1.1 Add formatted attribute.
      18:  * @subpackage Shopobjects\Price
      19:  */
      20: class Price {
    @@ -119,113 +123,117 @@ 

    Traits

    22: /** @var float The amount of the price. */ 23: protected $amount = 0.0; 24: - 25: /** @var String|null The tax type of the price. */ - 26: protected $taxType = null; + 25: /** @var String|null The curreny of the price. */ + 26: protected $currency = null; 27: - 28: /** @var String|null The curreny of the price. */ - 29: protected $currency = null; + 28: /** @var String|null The formatted price with currency. */ + 29: protected $formatted = null; 30: - 31: /** @var String|null The formatted price with currency. */ - 32: protected $formatted = null; + 31: /** @var String|null The tax type of the price. */ + 32: protected $taxType = null; 33: 34: /** - 35: * This is the constructor of the price object. + 35: * This is the constructor of the Price object. 36: * - 37: * @api - 38: * @author David Pauli <contact@david-pauli.de> + 37: * @author David Pauli <contact@david-pauli.de> + 38: * @param mixed[] $priceParamter The price parameter to create the Price object. 39: * @since 0.0.0 40: * @since 0.1.0 Add functionality to construct. 41: * @since 0.1.1 Parse formatted attribute. - 42: * @param mixed[] $priceParamter The price parameter. - 43: */ - 44: public function __construct($priceParameter) { + 42: */ + 43: public function __construct($priceParameter) { + 44: 45: if (InputValidator::isArray($priceParameter)) { 46: 47: if (!InputValidator::isEmptyArrayKey($priceParameter, "amount")) { - 48: $this->amount = $priceParameter['amount']; - 49: } - 50: if (!InputValidator::isEmptyArrayKey($priceParameter, "taxType")) { - 51: $this->taxType = $priceParameter['taxType']; - 52: } - 53: if (!InputValidator::isEmptyArrayKey($priceParameter, "currency")) { - 54: $this->currency = $priceParameter['currency']; + 48: + 49: $this->amount = $priceParameter['amount']; + 50: } + 51: + 52: if (!InputValidator::isEmptyArrayKey($priceParameter, "taxType")) { + 53: + 54: $this->taxType = $priceParameter['taxType']; 55: } - 56: if (!InputValidator::isEmptyArrayKey($priceParameter, "formatted")) { - 57: $this->formatted = $priceParameter['formatted']; - 58: } - 59: } - 60: } + 56: + 57: if (!InputValidator::isEmptyArrayKey($priceParameter, "currency")) { + 58: + 59: $this->currency = $priceParameter['currency']; + 60: } 61: - 62: /** - 63: * Returns the amount. - 64: * - 65: * @author David Pauli <contact@david-pauli.de> - 66: * @since 0.1.0 - 67: * @api - 68: * @return float Gets the amount. - 69: */ - 70: public function getAmount() { - 71: - 72: return $this->amount; - 73: } - 74: - 75: /** - 76: * Returns the tax type. - 77: * - 78: * @author David Pauli <contact@david-pauli.de> - 79: * @since 0.1.0 - 80: * @api - 81: * @return String Gets the tax type. - 82: */ - 83: public function getTaxType() { - 84: - 85: return $this->taxType; - 86: } - 87: - 88: /** - 89: * Returns the currency. - 90: * - 91: * @author David Pauli <contact@david-pauli.de> - 92: * @since 0.1.0 - 93: * @api - 94: * @return String Gets the currency. - 95: */ - 96: public function getCurrency() { + 62: if (!InputValidator::isEmptyArrayKey($priceParameter, "formatted")) { + 63: + 64: $this->formatted = $priceParameter['formatted']; + 65: } + 66: } + 67: } + 68: + 69: /** + 70: * Prints the Price object as a string. + 71: * + 72: * This function returns the setted attributes of the Price object. + 73: * + 74: * @author David Pauli <contact@david-pauli.de> + 75: * @since 0.1.1 + 76: * @return String The Price as a string. + 77: */ + 78: public function __toString() { + 79: + 80: return "<strong>Amount:</strong> " . $this->amount . "<br/>" . + 81: "<strong>Tax type:</strong> " . $this->taxType . "<br/>" . + 82: "<strong>Currency:</strong> " . $this->currency . "<br/>" . + 83: "<strong>Formatted:</strong> " . $this->formatted . "<br/>"; + 84: } + 85: + 86: /** + 87: * Returns the amount. + 88: * + 89: * @author David Pauli <contact@david-pauli.de> + 90: * @return float Gets the amount. + 91: * @since 0.1.0 + 92: */ + 93: public function getAmount() { + 94: + 95: return $this->amount; + 96: } 97: - 98: return $this->currency; - 99: } -100: -101: /** -102: * Returns the formatted price with currency. -103: * -104: * @author David Pauli <contact@david-pauli.de> -105: * @since 0.1.1 -106: * @api -107: * @return String Returns the price with currency formatted. -108: */ -109: public function getFormatted() { -110: -111: return $this->formatted; -112: } -113: -114: /** -115: * Prints the Price object as a string. -116: * -117: * This function returns the setted attributes of the Price object. -118: * -119: * @author David Pauli <contact@david-pauli.de> -120: * @since 0.1.1 -121: * @return String The Price as a string. -122: */ -123: public function __toString() { -124: -125: return "<strong>Amount:</strong> " . $this->amount . "<br/>" . -126: "<strong>Tax type:</strong> " . $this->taxType . "<br/>" . -127: "<strong>Currency:</strong> " . $this->currency . "<br/>" . -128: "<strong>Formatted:</strong> " . $this->formatted . "<br/>"; -129: } -130: } -131: ?>
    + 98: /** + 99: * Returns the currency. +100: * +101: * @author David Pauli <contact@david-pauli.de> +102: * @return String Gets the currency. +103: * @since 0.1.0 +104: */ +105: public function getCurrency() { +106: +107: return $this->currency; +108: } +109: +110: /** +111: * Returns the formatted price with currency. +112: * +113: * @author David Pauli <contact@david-pauli.de> +114: * @since 0.1.1 +115: * @api +116: * @return String Returns the price with currency formatted. +117: */ +118: public function getFormatted() { +119: +120: return $this->formatted; +121: } +122: +123: /** +124: * Returns the tax type. +125: * +126: * @author David Pauli <contact@david-pauli.de> +127: * @return String Gets the tax type. +128: * @since 0.1.0 +129: */ +130: public function getTaxType() { +131: +132: return $this->taxType; +133: } +134: } +135: ?> - + diff --git a/doc/source-class-ep6.PriceWithQuantity.html b/doc/source-class-ep6.PriceWithQuantity.html index 745a883..29fe780 100644 --- a/doc/source-class-ep6.PriceWithQuantity.html +++ b/doc/source-class-ep6.PriceWithQuantity.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,39 +101,39 @@

    Traits

      1: <?php
       2: /**
    -  3:  * This file represents the price with quantity class.
    +  3:  * This file represents the Price With Quantity class.
       4:  *
       5:  * @author David Pauli <contact@david-pauli.de>
       6:  * @since 0.1.0
       7:  */
       8: namespace ep6;
       9: /**
    - 10:  * This is the class for prices which has a quantity.
    + 10:  * This is the class for Prices which has a Quantity.
      11:  *
      12:  * @author David Pauli <contact@david-pauli.de>
    - 13:  * @since 0.1.0
    - 14:  * @since 0.1.1 This object is echoable.
    - 15:  * @since 0.1.1 Disallow the locale parameter.
    - 16:  * @package ep6
    + 13:  * @package ep6
    + 14:  * @since 0.1.0
    + 15:  * @since 0.1.1 This object is echoable.
    + 16:  * @since 0.1.1 Disallow the locale parameter.
      17:  * @subpackage Shopobjects\Price
      18:  */
      19: class PriceWithQuantity extends Price {
      20: 
      21:     /** @var int|null The quantity amount. */
    - 22:     private $quantityAmount = null;
    + 22:     protected $quantityAmount = null;
      23: 
    - 24:     /** @var String|null The localized quantity unit. */
    - 25:     private $quantityUnit = null;
    + 24:     /** @var String|null The quantity unit. */
    + 25:     protected $quantityUnit = null;
      26: 
      27:     /**
    - 28:      * This is the constructor of the price with quantity object.
    + 28:      * This is the constructor of the Price With Quantity object.
      29:      *
      30:      * @api
      31:      * @author David Pauli <contact@david-pauli.de>
    - 32:      * @since 0.1.0
    - 33:      * @since 0.1.1 No locale parameter is needed
    - 34:      * @param mixed[] $priceParameter The price parameter.
    - 35:      * @param mixed[] $quantityParameter The quantity parameter.
    + 32:      * @param mixed[] $priceParameter The price parameter.
    + 33:      * @param mixed[] $quantityParameter The quantity parameter.
    + 34:      * @since 0.1.0
    + 35:      * @since 0.1.1 No locale parameter is needed
      36:      */
      37:     public function __construct($priceParameter, $quantityParameter) {
      38: 
    @@ -138,60 +142,60 @@ 

    Traits

    41: if (InputValidator::isArray($quantityParameter)) { 42: 43: if (!InputValidator::isEmptyArrayKey($quantityParameter, "amount")) { - 44: $this->quantityAmount = $quantityParameter['amount']; - 45: } - 46: - 47: if (!InputValidator::isEmptyArrayKey($quantityParameter, "unit")) { - 48: $this->quantityUnit = $quantityParameter['unit']; - 49: } - 50: } - 51: } - 52: - 53: /** - 54: * Returns the quantity amount. - 55: * - 56: * @author David Pauli <contact@david-pauli.de> - 57: * @since 0.1.0 - 58: * @api - 59: * @return String Gets the quantity amount. - 60: */ - 61: public function getQuantityAmount() { - 62: - 63: return $this->quantityAmount; - 64: } + 44: + 45: $this->quantityAmount = $quantityParameter['amount']; + 46: } + 47: + 48: if (!InputValidator::isEmptyArrayKey($quantityParameter, "unit")) { + 49: + 50: $this->quantityUnit = $quantityParameter['unit']; + 51: } + 52: } + 53: } + 54: + 55: /** + 56: * Prints the Price With Quantity object as a string. + 57: * + 58: * This function returns the setted attributes of the Price With Quantity object. + 59: * + 60: * @author David Pauli <contact@david-pauli.de> + 61: * @return String The Price With Quantity as a string. + 62: * @since 0.1.1 + 63: */ + 64: public function __toString() { 65: - 66: /** - 67: * Returns the quantity unit. - 68: * - 69: * @author David Pauli <contact@david-pauli.de> - 70: * @since 0.1.0 - 71: * @since 0.1.1 No locale parameter is needed. - 72: * @api - 73: * @param String $locale The localization. - 74: * @return String Gets the quantity unit. - 75: */ - 76: public function getQuantityUnit() { - 77: - 78: return $this->quantityUnit; - 79: } - 80: - 81: /** - 82: * Prints the Price with quantity object as a string. - 83: * - 84: * This function returns the setted attributes of the Price with quantity object. - 85: * - 86: * @author David Pauli <contact@david-pauli.de> - 87: * @since 0.1.1 - 88: * @return String The Price with quantity as a string. - 89: */ - 90: public function __toString() { - 91: - 92: return "<strong>Amount:</strong> " . $this->amount . "<br/>" . - 93: "<strong>Tax type:</strong> " . $this->taxType . "<br/>" . - 94: "<strong>Currency:</strong> " . $this->currency . "<br/>" . - 95: "<strong>Formatted:</strong> " . $this->formatted . "<br/>" . - 96: "<strong>Quantity amount:</strong> " . $this->quantityAmount . "<br/>" . - 97: "<strong>Quantity unit:</strong> " . $this->quantityUnit . "<br/>"; + 66: return "<strong>Amount:</strong> " . $this->amount . "<br/>" . + 67: "<strong>Tax type:</strong> " . $this->taxType . "<br/>" . + 68: "<strong>Currency:</strong> " . $this->currency . "<br/>" . + 69: "<strong>Formatted:</strong> " . $this->formatted . "<br/>" . + 70: "<strong>Quantity amount:</strong> " . $this->quantityAmount . "<br/>" . + 71: "<strong>Quantity unit:</strong> " . $this->quantityUnit . "<br/>"; + 72: } + 73: + 74: /** + 75: * Returns the quantity amount. + 76: * + 77: * @author David Pauli <contact@david-pauli.de> + 78: * @return String Gets the quantity amount. + 79: * @since 0.1.0 + 80: */ + 81: public function getQuantityAmount() { + 82: + 83: return $this->quantityAmount; + 84: } + 85: + 86: /** + 87: * Returns the quantity unit. + 88: * + 89: * @author David Pauli <contact@david-pauli.de> + 90: * @param String $locale The localization. + 91: * @return String Gets the quantity unit. + 92: * @since 0.1.0 + 93: * @since 0.1.1 No locale parameter is needed. + 94: */ + 95: public function getQuantityUnit() { + 96: + 97: return $this->quantityUnit; 98: } 99: } 100: ?>
    @@ -202,6 +206,6 @@

    Traits

    - + diff --git a/doc/source-class-ep6.PrivacyPolicyInformation.html b/doc/source-class-ep6.PrivacyPolicyInformation.html index d12dd5c..281c07c 100644 --- a/doc/source-class-ep6.PrivacyPolicyInformation.html +++ b/doc/source-class-ep6.PrivacyPolicyInformation.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,51 +101,36 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the privacy policy information class.
    + 3:  * This file represents the Privacy Policy Information class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
      7:  */
      8: namespace ep6;
      9: /**
    -10:  * The privacy policy information.
    +10:  * The Privacy Policy Information.
     11:  *
     12:  * @author David Pauli <contact@david-pauli.de>
    -13:  * @since 0.0.0
    -14:  * @since 0.1.1 This object is now echoable.
    -15:  * @since 0.1.1 Unstatic every attributes.
    -16:  * @package ep6
    -17:  * @subpackage Shopobjects\Information
    -18:  * @see InformationTrait This trait has all information needed objects.
    -19:  */
    -20: class PrivacyPolicyInformation {
    -21: 
    -22:     use InformationTrait;
    +13:  * @package ep6
    +14:  * @see InformationTrait This trait has all information needed objects.
    +15:  * @see ErrorReporting This trait gives the error reporting functionality.
    +16:  * @since 0.0.0
    +17:  * @since 0.1.1 This object is now echoable.
    +18:  * @since 0.1.1 Unstatic every attributes.
    +19:  * @since 0.1.2 Add error reporting.
    +20:  * @subpackage Shopobjects\Information
    +21:  */
    +22: class PrivacyPolicyInformation {
     23: 
    -24:     /** @var String The REST path for privacy policy. */
    -25:     const RESTPATH = "legal/privacy-policy";
    -26: 
    -27:     /** @var int Timestamp in ms when the next request needs to be done. */
    -28:     private $NEXT_REQUEST_TIMESTAMP = 0;
    -29: 
    -30:     /**
    -31:      * Prints the Information object as a string.
    -32:      *
    -33:      * This function returns the setted values of the Information object.
    -34:      *
    -35:      * @author David Pauli <contact@david-pauli.de>
    -36:      * @since 0.1.1
    -37:      * @return String The Information as a string.
    -38:      */
    -39:     public function __toString() {
    -40: 
    -41:         return "<strong>Name:</strong> " . $this->NAME . "<br/>" .
    -42:                 "<strong>Navigation caption:</strong> " . $this->NAVIGATIONCAPTION . "<br/>" .
    -43:                 "<strong>Description:</strong> " . $this->DESCRIPTION . "<br/>" .
    -44:                 "<strong>Next allowed request time:</strong> " . $this->NEXT_REQUEST_TIMESTAMP . "<br/>";
    -45:     }
    -46: }
    -47: ?>
    +24: use Information, ErrorReporting; +25: +26: /** @var String The REST path for Privacy Policy Information. */ +27: const RESTPATH = "legal/privacy-policy"; +28: +29: /** @var int Timestamp in ms when the next request needs to be done. */ +30: private $NEXT_REQUEST_TIMESTAMP = 0; +31: } +32: ?> - + diff --git a/doc/source-class-ep6.Product.html b/doc/source-class-ep6.Product.html index a9ab26a..c48a426 100644 --- a/doc/source-class-ep6.Product.html +++ b/doc/source-class-ep6.Product.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -95,693 +99,1323 @@

    Traits

    -
      1: <?php
    -  2: /**
    -  3:  * This file represents the product class.
    -  4:  *
    -  5:  * @author David Pauli <contact@david-pauli.de>
    -  6:  * @since 0.0.0
    -  7:  */
    -  8: namespace ep6;
    -  9: /**
    - 10:  * This is the product class for a product in the shop.
    - 11:  *
    - 12:  * @author David Pauli <contact@david-pauli.de>
    - 13:  * @since 0.0.0
    - 14:  * @since 0.1.0 Add price information.
    - 15:  * @since 0.1.0 Function to delete itself.
    - 16:  * @since 0.1.0 Delete different Locales.
    - 17:  * @since 0.1.0 Implement Slideshow functionality.
    - 18:  * @since 0.1.0 Implement attribute functionality.
    - 19:  * @since 0.1.0 Implement stock level functionality.
    - 20:  * @since 0.1.1 This object can be printed with echo.
    - 21:  * @since 0.1.1 Don't use locale parameter in get functions.
    - 22:  * @since 0.1.1 Unstatic every attributes.
    - 23:  * @package ep6
    - 24:  * @subpackage Shopobjects\Product
    - 25:  */
    - 26: class Product {
    - 27: 
    - 28:     /** @var String The REST path to the product ressource. */
    - 29:     const RESTPATH = "products";
    - 30: 
    - 31:     /** @var String The REST path to the product ressource. */
    - 32:     const RESTPATH_ATTRIBUTES = "custom-attributes";
    - 33: 
    - 34:     /** @var String The REST path to the product ressource. */
    - 35:     const RESTPATH_STOCKLEVEL = "stock-level";
    - 36: 
    - 37:     /** @var String|null The product ID. */
    - 38:     private $productID = null;
    - 39: 
    - 40:     /** @var String|null The name of the product. */
    - 41:     private $name = null;
    - 42: 
    - 43:     /** @var String|null The short description. */
    - 44:     private $shortDescription = null;
    - 45: 
    - 46:     /** @var String|null The description. */
    - 47:     private $description = null;
    - 48: 
    - 49:     /** @var boolean Is this product for sale? */
    - 50:     private $forSale = true;
    - 51: 
    - 52:     /** @var boolean Is this product a special offer? */
    - 53:     private $specialOffer = false;
    - 54: 
    - 55:     /** @var String|null The text of availibility. */
    - 56:     private $availibilityText = null;
    - 57: 
    - 58:     /** @var Images[] This are the images in the four different possibilities. */
    - 59:     private $images = array();
    - 60: 
    - 61:     /** @var PriceWithQuantity|null Here the price is saved. */
    - 62:     private $price = null;
    - 63: 
    - 64:     /** @var Price|null Here the deposit price is saved. */
    - 65:     private $depositPrice = null;
    - 66: 
    - 67:     /** @var Price|null Here the eco participation price is saved. */
    - 68:     private $ecoParticipationPrice = null;
    - 69: 
    - 70:     /** @var Price|null Here the price with deposit is saved. */
    - 71:     private $withDepositPrice = null;
    - 72: 
    - 73:     /** @var Price|null Here the manufactor price is saved. */
    - 74:     private $manufactorPrice = null;
    - 75: 
    - 76:     /** @var Price|null Here the base price is saved. */
    - 77:     private $basePrice = null;
    - 78: 
    - 79:     /** @var ProductSlideshow|null This object saves the slideshow. */
    - 80:     private $slideshow = null;
    - 81: 
    - 82:     /** @var ProductAttribute[] This array saves all the attributes. */
    - 83:     private $attributes = array();
    - 84: 
    - 85:     /** @var float|null Space to save the stocklevel. */
    - 86:     private $stockLevel = null;
    - 87: 
    - 88:     /** @var int Timestamp in ms when the next request needs to be done. */
    - 89:     private $NEXT_REQUEST_TIMESTAMP = 0;
    - 90: 
    - 91:     /**
    - 92:      * This is the constructor of the product.
    - 93:      *
    - 94:      * @author David Pauli <contact@david-pauli.de>
    - 95:      * @since 0.0.0
    - 96:      * @since 0.1.0 Add price information.
    - 97:      * @since 0.1.0 Use a default Locale.
    - 98:      * @since 0.1.1 Dont use the locale parameter in calling the product price attribute.
    - 99:      * @api
    -100:      * @param mixed[] $productParameter The product to create as array.
    -101:      */
    -102:     public function __construct($productParameter) {
    -103: 
    -104:         if (!InputValidator::isArray($productParameter) ||
    -105:             InputValidator::isEmptyArray($productParameter)) {
    -106:             return;
    -107:         }
    -108: 
    -109:         // if the product comes from the shop API
    -110:         if (InputValidator::isArray($productParameter) &&
    -111:             !InputValidator::isEmptyArrayKey($productParameter, "productId")) {
    -112: 
    -113:             $this->productID = $productParameter['productId'];
    -114: 
    -115:             // load locale depended content
    -116:             if (!InputValidator::isEmptyArrayKey($productParameter, "forSale")) {
    -117:                 $this->forSale = $productParameter['forSale'];
    -118:             }
    -119:             if (!InputValidator::isEmptyArrayKey($productParameter, "specialOffer")) {
    -120:                 $this->specialOffer = $productParameter['specialOffer'];
    -121:             }
    -122:             if (!InputValidator::isEmptyArrayKey($productParameter, "name")) {
    -123:                 $this->name = $productParameter['name'];
    -124:             }
    -125:             if (!InputValidator::isEmptyArrayKey($productParameter, "shortDescription")) {
    -126:                 $this->shortDescription = $productParameter['shortDescription'];
    -127:             }
    -128:             if (!InputValidator::isEmptyArrayKey($productParameter, "description")) {
    -129:                 $this->description = $productParameter['description'];
    -130:             }
    -131:             if (!InputValidator::isEmptyArrayKey($productParameter, "availabilityText")) {
    -132:                 $this->availabilityText = $productParameter['availabilityText'];
    -133:             }
    -134: 
    -135:             // parse images
    -136:             if (!InputValidator::isEmptyArrayKey($productParameter, "images")) {
    -137:                 foreach ($productParameter['images'] as $image) {
    -138:                     if (InputValidator::isArray($image) &&
    -139:                         !InputValidator::isEmptyArrayKey($image, "classifier") &&
    -140:                         !InputValidator::isEmptyArrayKey($image, "url")) {
    -141:                         $this->images[$image['classifier']] = new Image($image['url']);
    -142:                     }
    -143:                 }
    -144:             }
    -145: 
    -146:             // parse price
    -147:             if (!InputValidator::isEmptyArrayKey($productParameter, "priceInfo")) {
    -148: 
    -149:                 $priceInformation = $productParameter['priceInfo'];
    -150: 
    -151:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "price") &&
    -152:                     !InputValidator::isEmptyArrayKey($priceInformation, "quantity")) {
    -153:                     $this->price = new PriceWithQuantity($priceInformation['price'], $priceInformation['quantity']);
    -154:                 }
    -155:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "depositPrice")) {
    -156:                     $this->depositPrice = new Price($priceInformation['depositPrice']);
    -157:                 }
    -158:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "ecoParticipationPrice")) {
    -159:                     $this->ecoParticipationPrice = new Price($priceInformation['ecoParticipationPrice']);
    -160:                 }
    -161:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "priceWithDeposits")) {
    -162:                     $this->withDepositPrice = new Price($priceInformation['priceWithDeposits']);
    -163:                 }
    -164:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "manufactorPrice")) {
    -165:                     $this->manufactorPrice = new Price($priceInformation['manufactorPrice']);
    -166:                 }
    -167:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "basePrice")) {
    -168:                     $this->basePrice = new Price($priceInformation['basePrice']);
    -169:                 }
    -170:             }
    -171:         }
    -172:     }
    -173: 
    -174:     /**
    -175:      * Returns the product id.
    -176:      *
    -177:      * @author David Pauli <contact@david-pauli.de>
    -178:      * @since 0.0.0
    -179:      * @api
    -180:      * @return String The product id.
    -181:      */
    -182:     public function getID() {
    -183: 
    -184:         return $this->productID;
    -185:     }
    -186: 
    -187:     /**
    -188:      * Returns the name in a specific localization.
    -189:      *
    -190:      * @author David Pauli <contact@david-pauli.de>
    -191:      * @since 0.0.0
    -192:      * @since 0.1.0 Use a default Locale.
    -193:      * @since 0.1.1 Fix to call function without locale parameter.
    -194:      * @api
    -195:      * @return String The name.
    -196:      */
    -197:     public function getName() {
    -198: 
    -199:         return $this->name;
    -200:     }
    -201: 
    -202:     /**
    -203:      * Returns the short description in a specific localization.
    -204:      *
    -205:      * @author David Pauli <contact@david-pauli.de>
    -206:      * @since 0.0.0
    -207:      * @since 0.1.0 Use a default Locale.
    -208:      * @since 0.1.1 Fix to call function without locale parameter.
    -209:      * @api
    -210:      * @return String The short description.
    -211:      */
    -212:     public function getShortDescription() {
    -213: 
    -214:         return $this->shortDescription;
    -215:     }
    -216: 
    -217:     /**
    -218:      * Returns the description in a specific localization.
    -219:      *
    -220:      * @author David Pauli <contact@david-pauli.de>
    -221:      * @since 0.0.0
    -222:      * @since 0.1.0 Use a default Locale.
    -223:      * @since 0.1.1 Fix to call function without locale parameter.
    -224:      * @api
    -225:      * @return String The description.
    -226:      */
    -227:     public function getDescription() {
    -228: 
    -229:         return $this->description;
    -230:     }
    -231: 
    -232:     /**
    -233:      * Returns true if it is for sale.
    -234:      *
    -235:      * @author David Pauli <contact@david-pauli.de>
    -236:      * @since 0.0.0
    -237:      * @api
    -238:      * @return boolean True if it is for sale, false if not.
    -239:      */
    -240:     public function isForSale() {
    -241: 
    -242:         return $this->forSale;
    -243:     }
    -244: 
    -245:     /**
    -246:      * Returns true if it is a special offer.
    -247:      *
    -248:      * @author David Pauli <contact@david-pauli.de>
    -249:      * @since 0.0.0
    -250:      * @api
    -251:      * @return boolean True if it is a special offer, false if not.
    -252:      */
    -253:     public function isSpecialOffer() {
    -254: 
    -255:         return $this->specialOffer;
    -256:     }
    -257: 
    -258:     /**
    -259:      * Returns the availibility text in a specific localization.
    -260:      *
    -261:      * @author David Pauli <contact@david-pauli.de>
    -262:      * @since 0.0.0
    -263:      * @since 0.1.0 Use a default Locale.
    -264:      * @since 0.1.1 Fix to call function without locale parameter.
    -265:      * @api
    -266:      * @return String The availibility text.
    -267:      */
    -268:     public function getAvailibilityText() {
    -269: 
    -270:         return $this->availibilityText;
    -271:     }
    -272: 
    -273:     /**
    -274:      * Returns the small image.
    -275:      *
    -276:      * @author David Pauli <contact@david-pauli.de>
    -277:      * @since 0.0.0
    -278:      * @api
    -279:      * @return Image The small image.
    -280:      */
    -281:     public function getSmallImage() {
    -282: 
    -283:         return !InputValidator::isEmptyArrayKey($this->images, "Small") ? $this->images["Small"] : null;
    -284:     }
    -285: 
    -286:     /**
    -287:      * Returns the medium image.
    -288:      *
    -289:      * @author David Pauli <contact@david-pauli.de>
    -290:      * @since 0.0.0
    -291:      * @api
    -292:      * @return Image The medium image.
    -293:      */
    -294:     public function getMediumImage() {
    -295: 
    -296:         return !InputValidator::isEmptyArrayKey($this->images, "Medium") ? $this->images["Medium"] : null;
    -297:     }
    -298: 
    -299:     /**
    -300:      * Returns the large image.
    -301:      *
    -302:      * @author David Pauli <contact@david-pauli.de>
    -303:      * @since 0.0.0
    -304:      * @api
    -305:      * @return Image The large image.
    -306:      */
    -307:     public function getLargeImage() {
    -308: 
    -309:         return !InputValidator::isEmptyArrayKey($this->images, "Large") ? $this->images["Large"] : null;
    -310:     }
    -311: 
    -312:     /**
    -313:      * Returns the hot deal image.
    -314:      *
    -315:      * @author David Pauli <contact@david-pauli.de>
    -316:      * @since 0.0.0
    -317:      * @api
    -318:      * @return Image The hot deal image.
    -319:      */
    -320:     public function getHotDealImage() {
    -321: 
    -322:         return !InputValidator::isEmptyArrayKey($this->images, "HotDeal") ? $this->images["HotDeal"] : null;
    -323:     }
    -324: 
    -325:     /**
    -326:      * Returns the price with quantity.
    -327:      *
    -328:      * @author David Pauli <contact@david-pauli.de>
    -329:      * @since 0.1.0
    -330:      * @api
    -331:      * @return PriceWithQuantity Gets the price with quantity.
    -332:      */
    -333:     public function getPrice() {
    -334: 
    -335:         return $this->price;
    -336:     }
    -337: 
    -338:     /**
    -339:      * Returns the deposit price.
    -340:      *
    -341:      * @author David Pauli <contact@david-pauli.de>
    -342:      * @since 0.1.0
    -343:      * @api
    -344:      * @return Price Gets the deposit price.
    -345:      */
    -346:     public function getDepositPrice() {
    -347: 
    -348:         return $this->depositPrice;
    -349:     }
    -350: 
    -351:     /**
    -352:      * Returns the eco participation price.
    -353:      *
    -354:      * @author David Pauli <contact@david-pauli.de>
    -355:      * @since 0.1.0
    -356:      * @api
    -357:      * @return Price Gets the eco participation price.
    -358:      */
    -359:     public function getEcoParticipationPrice() {
    -360: 
    -361:         return $this->ecoParticipationPrice;
    -362:     }
    -363: 
    -364:     /**
    -365:      * Returns the with deposit price.
    -366:      *
    -367:      * @author David Pauli <contact@david-pauli.de>
    -368:      * @since 0.1.0
    -369:      * @api
    -370:      * @return Price Gets the with deposit price.
    -371:      */
    -372:     public function getWithDepositPrice() {
    -373: 
    -374:         return $this->withDepositPrice;
    -375:     }
    -376: 
    -377:     /**
    -378:      * Returns the manufactor price.
    -379:      *
    -380:      * @author David Pauli <contact@david-pauli.de>
    -381:      * @since 0.1.0
    -382:      * @api
    -383:      * @return Price Gets the manufactor price.
    -384:      */
    -385:     public function getManufactorPrice() {
    -386: 
    -387:         return $this->manufactorPrice;
    -388:     }
    -389: 
    -390:     /**
    -391:      * Returns the base price.
    -392:      *
    -393:      * @author David Pauli <contact@david-pauli.de>
    -394:      * @since 0.1.0
    -395:      * @api
    -396:      * @return Price Gets the base price.
    -397:      */
    -398:     public function getBasePrice() {
    -399: 
    -400:         return $this->basePrice;
    -401:     }
    -402: 
    -403:     /**
    -404:      * Returns the slideshow.
    -405:      *
    -406:      * @author David Pauli <contact@david-pauli.de>
    -407:      * @since 0.1.0
    -408:      * @since 0.1.1 Slideshows are not reloadable since now.
    -409:      * @api
    -410:      * @return ProductSlideshow Gets the product slideshow.
    -411:      */
    -412:     public function getSlideshow() {
    -413: 
    -414:         // if the slideshow is not loaded until now
    -415:         if (InputValidator::isEmpty($this->slideshow)) {
    -416:             $this->slideshow = new ProductSlideshow($this->productID);
    -417:         }
    -418:         return $this->slideshow;
    -419:     }
    -420: 
    -421:     /**
    -422:      * Returns the product attributes.
    -423:      *
    -424:      * @author David Pauli <contact@david-pauli.de>
    -425:      * @since 0.1.0
    -426:      * @since 0.1.1 Unstatic every attributes.
    -427:      * @api
    -428:      * @return ProductAttributes[] Gets the product attributes in an array.
    -429:      */
    -430:     public function getAttributes() {
    -431: 
    -432:         $timestamp = (int) (microtime(true) * 1000);
    -433: 
    -434:         // if the attribute is not loaded until now
    -435:         if (InputValidator::isEmptyArray($this->attributes) ||
    -436:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    -437:             $this->loadAttributes();
    -438:         }
    -439:         return $this->attributes;
    -440:     }
    -441: 
    -442:     /**
    -443:      * Returns the product attributes.
    -444:      *
    -445:      * @author David Pauli <contact@david-pauli.de>
    -446:      * @since 0.1.0
    -447:      * @api
    -448:      * @param int $key The number of product attribute to get.
    -449:      * @return ProductAttributes|null Gets the required product attributes.
    -450:      */
    -451:     public function getAttribute($key) {
    -452: 
    -453:         $timestamp = (int) (microtime(true) * 1000);
    -454: 
    -455:         // if the attribute is not loaded until now
    -456:         if (InputValidator::isEmptyArrayKey($this->attributes, $key) ||
    -457:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    -458:             $this->loadAttributes();
    -459:         }
    -460: 
    -461:         if (InputValidator::isEmptyArrayKey($this->attributes, $key)) {
    -462:             return null;
    -463:         }
    -464:         return $this->attributes[$key];
    -465:     }
    -466: 
    -467:     /**
    -468:      * Loads the product attributes.
    -469:      *
    -470:      * @author David Pauli <contact@david-pauli.de>
    -471:      * @since 0.1.0
    -472:      * @since 0.1.1 Unstatic every attributes.
    -473:      */
    -474:     private function loadAttributes() {
    -475: 
    -476:         // if parameter is wrong or GET is blocked
    -477:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
    -478:             return;
    -479:         }
    -480: 
    -481:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_ATTRIBUTES);
    -482: 
    -483:         // if respond is empty
    -484:         if (InputValidator::isEmpty($content)) {
    -485:             return;
    -486:         }
    -487: 
    -488:         // if there are items
    -489:         if (InputValidator::isEmptyArrayKey($content, "items")) {
    -490:             Logger::error("Respond for " . self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_ATTRIBUTES . "can not be interpreted.");
    -491:             return;
    -492:         }
    -493: 
    -494:         // is there any attribute found: load the attribute.
    -495:         foreach ($content['items'] as $number => $attribute) {
    -496: 
    -497:             // parse every attribute
    -498:             $this->attributes[$number] = new ProductAttribute($attribute);
    -499:         }
    -500: 
    -501:         // update timestamp when make the next request
    -502:         $timestamp = (int) (microtime(true) * 1000);
    -503:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    -504:     }
    -505: 
    -506:     /**
    -507:      * Returns the stock level.
    -508:      *
    -509:      * @author David Pauli <contact@david-pauli.de>
    -510:      * @since 0.1.0
    -511:      * @since 0.1.1 Unstatic every attributes.
    -512:      * @api
    -513:      * @return float|null The stock level of the product.
    -514:      */
    -515:     public function getStockLevel() {
    -516: 
    -517:         $timestamp = (int) (microtime(true) * 1000);
    -518: 
    -519:         // if the attribute is not loaded until now
    -520:         if (InputValidator::isEmpty($this->stockLevel) ||
    -521:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    -522:             $this->loadStockLevel();
    -523:         }
    -524: 
    -525:         return $this->stockLevel;
    -526:     }
    -527: 
    -528:     /**
    -529:      * Increases the stock level.
    -530:      *
    -531:      * @author David Pauli <contact@david-pauli.de>
    -532:      * @since 0.1.0
    -533:      * @api
    -534:      * @param float $step The value the stock level should be increased, default value is 1.
    -535:      * @return float|null The new stock level of the product.
    -536:      */
    -537:     public function increaseStockLevel($step = 1.0) {
    -538: 
    -539:         $this->getStockLevel();
    -540: 
    -541:         // cast int to float
    -542:         if (InputValidator::isInt($step)) {
    -543:             $step = (float) $step;
    -544:         }
    -545: 
    -546:         if (!InputValidator::isRangedFloat($step, 0.0)) {
    -547:             return $this->stockLevel;
    -548:         }
    -549:         $this->changeStockLevel((float) $step);
    -550: 
    -551:         return $this->stockLevel;
    -552:     }
    -553: 
    -554:     /**
    -555:      * Decreases the stock level.
    -556:      *
    -557:      * @author David Pauli <contact@david-pauli.de>
    -558:      * @since 0.1.0
    -559:      * @api
    -560:      * @param float $step The value the stock level should be decreased, default value is 1.
    -561:      * @return float|null The new stock level of the product.
    -562:      */
    -563:     public function decreaseStockLevel($step = 1.0) {
    -564: 
    -565:         $this->getStockLevel();
    -566: 
    -567:         // cast int to float
    -568:         if (InputValidator::isInt($step)) {
    -569:             $step = (float) $step;
    -570:         }
    -571: 
    -572:         if (!InputValidator::isRangedFloat($step, 0.0)) {
    -573:             return $this->stockLevel;
    -574:         }
    -575:         $this->changeStockLevel((float) $step * -1);
    -576: 
    -577:         return $this->stockLevel;
    -578:     }
    -579: 
    -580:     /**
    -581:      * Loads the stock level.
    -582:      *
    -583:      * @author David Pauli <contact@david-pauli.de>
    -584:      * @since 0.1.0
    -585:      * @since 0.1.1 Unstatic every attributes.
    -586:      */
    -587:     private function loadStockLevel() {
    -588: 
    -589:         // if parameter is wrong or GET is blocked
    -590:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
    -591:             return;
    -592:         }
    -593: 
    -594:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL);
    -595: 
    -596:         // if respond is empty
    -597:         if (InputValidator::isEmpty($content) ||
    -598:             InputValidator::isEmptyArrayKey($content, "stocklevel")) {
    -599:             return;
    -600:         }
    -601: 
    -602:         $this->stockLevel = (float) $content["stocklevel"];
    -603: 
    -604:         // update timestamp when make the next request
    -605:         $timestamp = (int) (microtime(true) * 1000);
    -606:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    -607:     }
    -608:     /**
    -609:      * Loads the stock level.
    -610:      *
    -611:      * @author David Pauli <contact@david-pauli.de>
    -612:      * @since 0.1.0
    -613:      * @since 0.1.1 Unstatic every attributes.
    -614:      * @param float $step The step to change.
    -615:      */
    -616:     private function changeStockLevel($step) {
    -617: 
    -618:         // if parameter is wrong or GET is blocked
    -619:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::PUT) ||
    -620:             !InputValidator::isFloat($step)) {
    -621:             return;
    -622:         }
    -623: 
    -624:         $postfields = array("changeStocklevel" => $step);
    -625:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL, $postfields);
    -626: 
    -627:         // if respond is empty
    -628:         if (InputValidator::isEmpty($content) ||
    -629:             InputValidator::isEmptyArrayKey($content, "stocklevel")) {
    -630:             return;
    -631:         }
    -632: 
    -633:         $this->stockLevel = (float) $content["stocklevel"];
    -634: 
    -635:         // update timestamp when make the next request
    -636:         $timestamp = (int) (microtime(true) * 1000);
    -637:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    -638:     }
    -639: 
    -640:     /**
    -641:      * Deletes itself.
    -642:      *
    -643:      * Dont use this function. To delete a product its better to use $shop->deleteProduct($product).
    -644:      *
    -645:      * @author David Pauli <contact@david-pauli.de>
    -646:      * @since 0.1.0
    -647:      * @since 0.1.1 Unstatic every attributes.
    -648:      * @return boolean True if the deletion was successful, false if not.
    -649:      */
    -650:     public function delete() {
    -651: 
    -652:         // if request method is blocked
    -653:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::DELETE)) {
    -654:             return false;
    -655:         }
    -656: 
    -657:         RESTClient::send(self::RESTPATH . "/" . $this->productID);
    -658: 
    -659:         return true;
    -660:     }
    -661: 
    -662:     /**
    -663:      * Prints the Product object as a string.
    -664:      *
    -665:      * This function returns the setted values of the Product object.
    -666:      *
    -667:      * @author David Pauli <contact@david-pauli.de>
    -668:      * @since 0.1.1
    -669:      * @return String The Product as a string.
    -670:      */
    -671:     public function __toString() {
    -672: 
    -673:         return "<strong>Product ID:</strong> " . $this->productID . "<br/>" .
    -674:                 "<strong>Name:</strong> " . $this->name . "<br/>" .
    -675:                 "<strong>Short description:</strong> " . $this->shortDescription . "<br/>" .
    -676:                 "<strong>Description:</strong> " . $this->description . "<br/>" .
    -677:                 "<strong>For sale:</strong> " . $this->forSale . "<br/>" .
    -678:                 "<strong>Special offer:</strong> " . $this->specialOffer . "<br/>" .
    -679:                 "<strong>Availibility text:</strong> " . $this->availibilityText . "<br/>" .
    -680:                 "<strong>Images:</strong> " . print_r($this->images) . "<br/>" .
    -681:                 "<strong>Price:</strong> " . $this->price . "<br/>" .
    -682:                 "<strong>Deposit price:</strong> " . $this->depositPrice . "<br/>" .
    -683:                 "<strong>Ecoparticipation price:</strong> " . $this->ecoParticipationPrice . "<br/>";
    -684:     }
    -685: }
    -686: 
    -687: ?>
    +
       1: <?php
    +   2: /**
    +   3:  * This file represents the Product class.
    +   4:  *
    +   5:  * @author David Pauli <contact@david-pauli.de>
    +   6:  * @since 0.0.0
    +   7:  */
    +   8: namespace ep6;
    +   9: /**
    +  10:  * This is the product class for a Product in the shop.
    +  11:  *
    +  12:  * @author David Pauli <contact@david-pauli.de>
    +  13:  * @package ep6
    +  14:  * @since 0.0.0
    +  15:  * @since 0.1.0 Add price information.
    +  16:  * @since 0.1.0 Function to delete itself.
    +  17:  * @since 0.1.0 Delete different Locales.
    +  18:  * @since 0.1.0 Implement Slideshow functionality.
    +  19:  * @since 0.1.0 Implement attribute functionality.
    +  20:  * @since 0.1.0 Implement stock level functionality.
    +  21:  * @since 0.1.1 This object can be printed with echo.
    +  22:  * @since 0.1.1 Don't use locale parameter in get functions.
    +  23:  * @since 0.1.1 Unstatic every attributes.
    +  24:  * @since 0.1.2 Insert the Setters.
    +  25:  * @since 0.1.2 Add error reporting.
    +  26:  * @subpackage Shopobjects\Product
    +  27:  */
    +  28: class Product {
    +  29: 
    +  30:     use ErrorReporting;
    +  31: 
    +  32:     /** @var String The REST path to the product ressource. */
    +  33:     const RESTPATH = "products";
    +  34: 
    +  35:     /** @var String The REST path to the product ressource. */
    +  36:     const RESTPATH_ATTRIBUTES = "custom-attributes";
    +  37: 
    +  38:     /** @var String The REST path to the product ressource. */
    +  39:     const RESTPATH_STOCKLEVEL = "stock-level";
    +  40: 
    +  41:     /** @var ProductAttribute[] This array saves all the attributes. */
    +  42:     private $attributes = array();
    +  43: 
    +  44:     /** @var String|null The text of availibility. */
    +  45:     private $availibilityText = null;
    +  46: 
    +  47:     /** @var ProductPrice|null Here the base price is saved. */
    +  48:     private $basePrice = null;
    +  49: 
    +  50:     /** @var ProductPrice|null Here the deposit price is saved. */
    +  51:     private $depositPrice = null;
    +  52: 
    +  53:     /** @var String|null The description. */
    +  54:     private $description = null;
    +  55: 
    +  56:     /** @var String|null Space to save the EAN. */
    +  57:     private $ean = null;
    +  58: 
    +  59:     /** @var ProductPrice|null Here the eco participation price is saved. */
    +  60:     private $ecoParticipationPrice = null;
    +  61: 
    +  62:     /** @var String|null This is the energy label. */
    +  63:     private $energyLabelsString = null;
    +  64: 
    +  65:     /** @var String|null This are the essential features. */
    +  66:     private $essentialFeatures = null;
    +  67: 
    +  68:     /** @var boolean Is this product for sale? */
    +  69:     private $forSale = true;
    +  70: 
    +  71:     /** @var String|null Here the manufacturer name is saved. */
    +  72:     private $manufacturer = null;
    +  73: 
    +  74:     /** @var ProductPrice|null Here the manufacturer price is saved. */
    +  75:     private $manufacturerPrice = null;
    +  76: 
    +  77:     /** @var String|null The name of the product. */
    +  78:     private $name = null;
    +  79: 
    +  80:     /** @var Images[] This are the images in the four different possibilities. */
    +  81:     private $images = array();
    +  82: 
    +  83:     /** @var ProductPriceWithQuantity|null Here the price is saved. */
    +  84:     private $price = null;
    +  85: 
    +  86:     /** @var String|null The product ID. */
    +  87:     private $productID = null;
    +  88: 
    +  89:     /** @var String|null The product number. */
    +  90:     private $productNumber = null;
    +  91: 
    +  92:     /** @var String[] Array to save the setted keywords. */
    +  93:     private $searchKeywords = array();
    +  94: 
    +  95:     /** @var String|null The short description. */
    +  96:     private $shortDescription = null;
    +  97: 
    +  98:     /** @var ProductSlideshow|null This object saves the slideshow. */
    +  99:     private $slideshow = null;
    + 100: 
    + 101:     /** @var boolean Is this product a special offer? */
    + 102:     private $specialOffer = false;
    + 103: 
    + 104:     /** @var float|null Space to save the stocklevel. */
    + 105:     private $stockLevel = null;
    + 106: 
    + 107:     /** @var String|null Space to save the UPC. */
    + 108:     private $upc = null;
    + 109: 
    + 110:     /** @var ProductPrice|null Here the price with deposit is saved. */
    + 111:     private $withDepositPrice = null;
    + 112: 
    + 113:     /** @var int Timestamp in ms when the next request needs to be done. */
    + 114:     private $NEXT_REQUEST_TIMESTAMP = 0;
    + 115: 
    + 116:     /**
    + 117:      * This is the constructor of the Product.
    + 118:      *
    + 119:      * @author David Pauli <contact@david-pauli.de>
    + 120:      * @param mixed[] $productParameter The product to create as array.
    + 121:      * @since 0.0.0
    + 122:      * @since 0.1.0 Add price information.
    + 123:      * @since 0.1.0 Use a default Locale.
    + 124:      * @since 0.1.1 Dont use the locale parameter in calling the product price attribute.
    + 125:      * @since 0.1.2 Exclude the REST request to the load() function.
    + 126:      * @since 0.1.2 Add error reporting.
    + 127:      */
    + 128:     public function __construct($productParameter) {
    + 129: 
    + 130:         if (!InputValidator::isArray($productParameter) ||
    + 131:             InputValidator::isEmptyArray($productParameter)) {
    + 132: 
    + 133:             $this->errorSet("P-1");
    + 134:             Logger::warning("ep6\Product\nProduct parameter " . $productParameter . " to create product is invalid.");
    + 135:             return;
    + 136:         }
    + 137: 
    + 138:         self::load($productParameter);
    + 139:     }
    + 140: 
    + 141:     /**
    + 142:      * Prints the Product object as a string.
    + 143:      *
    + 144:      * This function returns the setted values of the Product object.
    + 145:      *
    + 146:      * @author David Pauli <contact@david-pauli.de>
    + 147:      * @return String The Product as a string.
    + 148:      * @since 0.1.1
    + 149:      */
    + 150:     public function __toString() {
    + 151: 
    + 152:         return "<strong>Product ID:</strong> " . $this->productID . "<br/>" .
    + 153:                 "<strong>Name:</strong> " . $this->name . "<br/>" .
    + 154:                 "<strong>Short description:</strong> " . $this->shortDescription . "<br/>" .
    + 155:                 "<strong>Description:</strong> " . $this->description . "<br/>" .
    + 156:                 "<strong>For sale:</strong> " . $this->forSale . "<br/>" .
    + 157:                 "<strong>Special offer:</strong> " . $this->specialOffer . "<br/>" .
    + 158:                 "<strong>Availibility text:</strong> " . $this->availibilityText . "<br/>" .
    + 159:                 "<strong>Images:</strong> " . print_r($this->images) . "<br/>" .
    + 160:                 "<strong>Price:</strong> " . $this->price . "<br/>" .
    + 161:                 "<strong>Deposit price:</strong> " . $this->depositPrice . "<br/>" .
    + 162:                 "<strong>Ecoparticipation price:</strong> " . $this->ecoParticipationPrice . "<br/>";
    + 163:     }
    + 164: 
    + 165:     /**
    + 166:      * Decreases the stock level.
    + 167:      *
    + 168:      * @author David Pauli <contact@david-pauli.de>
    + 169:      * @param float $step The value the stock level should be decreased, default value is 1.
    + 170:      * @return float|null The new stock level of the product.
    + 171:      * @since 0.1.0
    + 172:      * @since 0.1.2 Add error reporting.
    + 173:      */
    + 174:     public function decreaseStockLevel($step = 1.0) {
    + 175: 
    + 176:         $this->errorReset();
    + 177: 
    + 178:         $this->getStockLevel();
    + 179: 
    + 180:         // cast int to float
    + 181:         if (InputValidator::isInt($step)) {
    + 182: 
    + 183:             $step = (float) $step;
    + 184:         }
    + 185: 
    + 186:         if (!InputValidator::isRangedFloat($step, 0.0)) {
    + 187: 
    + 188:             return $this->stockLevel;
    + 189:         }
    + 190: 
    + 191:         $this->changeStockLevel((float) $step * -1);
    + 192: 
    + 193:         return $this->stockLevel;
    + 194:     }
    + 195: 
    + 196:     /**
    + 197:      * Deletes itself.
    + 198:      *
    + 199:      * Dont use this function. To delete a product its better to use $shop->deleteProduct($product).
    + 200:      *
    + 201:      * @author David Pauli <contact@david-pauli.de>
    + 202:      * @since 0.1.0
    + 203:      * @since 0.1.1 Unstatic every attributes.
    + 204:      * @since 0.1.2 Add error reporting.
    + 205:      * @return boolean True if the deletion was successful, false if not.
    + 206:      */
    + 207:     public function delete() {
    + 208: 
    + 209:         // if request method is blocked
    + 210:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::DELETE)) {
    + 211: 
    + 212:             $this->errorSet("RESTC-9");
    + 213:             return false;
    + 214:         }
    + 215: 
    + 216:         RESTClient::send(self::RESTPATH . "/" . $this->productID);
    + 217: 
    + 218:         return true;
    + 219:     }
    + 220: 
    + 221:     /**
    + 222:      * Returns the product attributes.
    + 223:      *
    + 224:      * @author David Pauli <contact@david-pauli.de>
    + 225:      * @param int $key The number of product attribute to get.
    + 226:      * @return ProductAttributes|null Gets the required product attributes.
    + 227:      * @since 0.1.0
    + 228:      * @since 0.1.2 Add error reporting.
    + 229:      */
    + 230:     public function getAttribute($key) {
    + 231: 
    + 232:         $this->errorReset();
    + 233:         $timestamp = (int) (microtime(true) * 1000);
    + 234: 
    + 235:         // if the attribute is not loaded until now
    + 236:         if (InputValidator::isEmptyArrayKey($this->attributes, $key) ||
    + 237:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    + 238: 
    + 239:             $this->loadAttributes();
    + 240:         }
    + 241: 
    + 242:         if (InputValidator::isEmptyArrayKey($this->attributes, $key)) {
    + 243: 
    + 244:             $this->errorSet("P-3");
    + 245:             Logger::warning("ep6\Product\nThe attribute " . $key . " is not defined in the product.");
    + 246:             return null;
    + 247:         }
    + 248: 
    + 249:         return $this->attributes[$key];
    + 250:     }
    + 251: 
    + 252:     /**
    + 253:      * Returns the product attributes.
    + 254:      *
    + 255:      * @author David Pauli <contact@david-pauli.de>
    + 256:      * @return ProductAttributes[] Gets the product attributes in an array.
    + 257:      * @since 0.1.0
    + 258:      * @since 0.1.1 Unstatic every attributes.
    + 259:      * @since 0.1.2 Add error reporting.
    + 260:      */
    + 261:     public function getAttributes() {
    + 262: 
    + 263:         $this->errorReset();
    + 264:         $timestamp = (int) (microtime(true) * 1000);
    + 265: 
    + 266:         // if the attribute is not loaded until now
    + 267:         if (InputValidator::isEmptyArray($this->attributes) ||
    + 268:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    + 269: 
    + 270:             $this->loadAttributes();
    + 271:         }
    + 272: 
    + 273:         return $this->attributes;
    + 274:     }
    + 275: 
    + 276:     /**
    + 277:      * Returns the availibility text.
    + 278:      *
    + 279:      * @author David Pauli <contact@david-pauli.de>
    + 280:      * @return String The availibility text.
    + 281:      * @since 0.0.0
    + 282:      * @since 0.1.0 Use a default Locale.
    + 283:      * @since 0.1.1 Fix to call function without locale parameter.
    + 284:      * @since 0.1.2 Add error reporting.
    + 285:      */
    + 286:     public function getAvailibilityText() {
    + 287: 
    + 288:         $this->errorReset();
    + 289: 
    + 290:         return $this->availibilityText;
    + 291:     }
    + 292: 
    + 293:     /**
    + 294:      * Returns the base price.
    + 295:      *
    + 296:      * @author David Pauli <contact@david-pauli.de>
    + 297:      * @return ProductPrice Gets the base price.
    + 298:      * @since 0.1.0
    + 299:      * @since 0.1.2 Add error reporting.
    + 300:      */
    + 301:     public function getBasePrice() {
    + 302: 
    + 303:         $this->errorReset();
    + 304: 
    + 305:         return $this->basePrice;
    + 306:     }
    + 307: 
    + 308:     /**
    + 309:      * Returns the deposit price.
    + 310:      *
    + 311:      * @author David Pauli <contact@david-pauli.de>
    + 312:      * @return ProductPrice Gets the deposit price.
    + 313:      * @since 0.1.0
    + 314:      * @since 0.1.2 Add error reporting.
    + 315:      */
    + 316:     public function getDepositPrice() {
    + 317: 
    + 318:         $this->errorReset();
    + 319: 
    + 320:         return $this->depositPrice;
    + 321:     }
    + 322: 
    + 323:     /**
    + 324:      * Returns the description.
    + 325:      *
    + 326:      * @author David Pauli <contact@david-pauli.de>
    + 327:      * @return String The description.
    + 328:      * @since 0.0.0
    + 329:      * @since 0.1.0 Use a default Locale.
    + 330:      * @since 0.1.1 Fix to call function without locale parameter.
    + 331:      * @since 0.1.2 Add error reporting.
    + 332:      */
    + 333:     public function getDescription() {
    + 334: 
    + 335:         $this->errorReset();
    + 336: 
    + 337:         return $this->description;
    + 338:     }
    + 339: 
    + 340:     /**
    + 341:      * Returns the EAN.
    + 342:      *
    + 343:      * @author David Pauli <contact@david-pauli.de>
    + 344:      * @return String Gets the EAN.
    + 345:      * @since 0.1.2
    + 346:      */
    + 347:     public function getEAN() {
    + 348: 
    + 349:         $this->errorReset();
    + 350: 
    + 351:         return $this->EAN;
    + 352:     }
    + 353: 
    + 354:     /**
    + 355:      * Returns the eco participation price.
    + 356:      *
    + 357:      * @author David Pauli <contact@david-pauli.de>
    + 358:      * @return ProductPrice Gets the eco participation price.
    + 359:      * @since 0.1.0
    + 360:      * @since 0.1.2 Add error reporting.
    + 361:      */
    + 362:     public function getEcoParticipationPrice() {
    + 363: 
    + 364:         $this->errorReset();
    + 365: 
    + 366:         return $this->ecoParticipationPrice;
    + 367:     }
    + 368: 
    + 369:     /**
    + 370:      * Returns the energy labels string.
    + 371:      *
    + 372:      * @author David Pauli <contact@david-pauli.de>
    + 373:      * @return String Gets the energy labels string.
    + 374:      * @since 0.1.2
    + 375:      */
    + 376:     public function getEnergyLabelsString() {
    + 377: 
    + 378:         $this->errorReset();
    + 379: 
    + 380:         return $this->energyLabelsString;
    + 381:     }
    + 382: 
    + 383:     /**
    + 384:      * Returns the essential features.
    + 385:      *
    + 386:      * @author David Pauli <contact@david-pauli.de>
    + 387:      * @return String Gets the essential features.
    + 388:      * @since 0.1.2
    + 389:      */
    + 390:     public function getEssentialFeatures() {
    + 391: 
    + 392:         $this->errorReset();
    + 393: 
    + 394:         return $this->essentialFeatures;
    + 395:     }
    + 396: 
    + 397:     /**
    + 398:      * Returns the hot deal image.
    + 399:      *
    + 400:      * @author David Pauli <contact@david-pauli.de>
    + 401:      * @return Image The hot deal image.
    + 402:      * @since 0.0.0
    + 403:      * @since 0.1.2 Add error reporting.
    + 404:      */
    + 405:     public function getHotDealImage() {
    + 406: 
    + 407:         $this->errorReset();
    + 408: 
    + 409:         return !InputValidator::isEmptyArrayKey($this->images, "HotDeal") ? $this->images["HotDeal"] : null;
    + 410:     }
    + 411: 
    + 412:     /**
    + 413:      * Returns the product id.
    + 414:      *
    + 415:      * @author David Pauli <contact@david-pauli.de>
    + 416:      * @return String The product id.
    + 417:      * @since 0.0.0
    + 418:      * @since 0.1.2 Add error reporting.
    + 419:      */
    + 420:     public function getID() {
    + 421: 
    + 422:         $this->errorReset();
    + 423: 
    + 424:         return $this->productID;
    + 425:     }
    + 426: 
    + 427:     /**
    + 428:      * Returns the large image.
    + 429:      *
    + 430:      * @author David Pauli <contact@david-pauli.de>
    + 431:      * @return Image The large image.
    + 432:      * @since 0.0.0
    + 433:      * @since 0.1.2 Add error reporting.
    + 434:      */
    + 435:     public function getLargeImage() {
    + 436: 
    + 437:         $this->errorReset();
    + 438: 
    + 439:         return !InputValidator::isEmptyArrayKey($this->images, "Large") ? $this->images["Large"] : null;
    + 440:     }
    + 441: 
    + 442:     /**
    + 443:      * Returns the name of the manufacturer.
    + 444:      *
    + 445:      * @author David Pauli <contact@david-pauli.de>
    + 446:      * @return String Gets the name of the manufacturer.
    + 447:      * @since 0.1.2
    + 448:      */
    + 449:     public function getManufacturer() {
    + 450: 
    + 451:         $this->errorReset();
    + 452: 
    + 453:         return $this->manufacturer;
    + 454:     }
    + 455: 
    + 456:     /**
    + 457:      * Returns the manufacturer price.
    + 458:      *
    + 459:      * @author David Pauli <contact@david-pauli.de>
    + 460:      * @return ProductPrice Gets the manufacturer price.
    + 461:      * @since 0.1.0
    + 462:      * @since 0.1.2 Add error reporting.
    + 463:      */
    + 464:     public function getManufacturerPrice() {
    + 465: 
    + 466:         $this->errorReset();
    + 467: 
    + 468:         return $this->manufacturerPrice;
    + 469:     }
    + 470: 
    + 471:     /**
    + 472:      * Returns the medium image.
    + 473:      *
    + 474:      * @author David Pauli <contact@david-pauli.de>
    + 475:      * @return Image The medium image.
    + 476:      * @since 0.0.0
    + 477:      * @since 0.1.2 Add error reporting.
    + 478:      */
    + 479:     public function getMediumImage() {
    + 480: 
    + 481:         $this->errorReset();
    + 482: 
    + 483:         return !InputValidator::isEmptyArrayKey($this->images, "Medium") ? $this->images["Medium"] : null;
    + 484:     }
    + 485: 
    + 486:     /**
    + 487:      * Returns the name.
    + 488:      *
    + 489:      * @author David Pauli <contact@david-pauli.de>
    + 490:      * @return String The name.
    + 491:      * @since 0.0.0
    + 492:      * @since 0.1.0 Use a default Locale.
    + 493:      * @since 0.1.1 Fix to call function without locale parameter.
    + 494:      * @since 0.1.2 Add error reporting.
    + 495:      */
    + 496:     public function getName() {
    + 497: 
    + 498:         $this->errorReset();
    + 499: 
    + 500:         return $this->name;
    + 501:     }
    + 502: 
    + 503:     /**
    + 504:      * Returns the amount of search keywords.
    + 505:      *
    + 506:      * @author David Pauli <contact@david-pauli.de>
    + 507:      * @return int Gets the number of search keywords.
    + 508:      * @since 0.1.2
    + 509:      */
    + 510:     public function getNumberOfSearchKeywords() {
    + 511: 
    + 512:         $this->errorReset();
    + 513: 
    + 514:         return sizeof($this->searchKeywords);
    + 515:     }
    + 516: 
    + 517:     /**
    + 518:      * Returns the product price with quantity.
    + 519:      *
    + 520:      * @author David Pauli <contact@david-pauli.de>
    + 521:      * @return ProductPriceWithQuantity Gets the product price with quantity.
    + 522:      * @since 0.1.0
    + 523:      * @since 0.1.2 Add error reporting.
    + 524:      */
    + 525:     public function getPrice() {
    + 526: 
    + 527:         $this->errorReset();
    + 528: 
    + 529:         return $this->price;
    + 530:     }
    + 531: 
    + 532:     /**
    + 533:      * Returns the product number.
    + 534:      *
    + 535:      * @author David Pauli <contact@david-pauli.de>
    + 536:      * @return String Gets the product number.
    + 537:      * @since 0.1.2
    + 538:      */
    + 539:     public function getProductNumber() {
    + 540: 
    + 541:         $this->errorReset();
    + 542: 
    + 543:         return $this->productNumber;
    + 544:     }
    + 545: 
    + 546:     /**
    + 547:      * Returns the search keyword.
    + 548:      *
    + 549:      * @author David Pauli <contact@david-pauli.de>
    + 550:      * @return String Gets a specific search keyword,, starting with 1.
    + 551:      * @param int $number The number of the search keyword which is required.
    + 552:      * @since 0.1.2
    + 553:      */
    + 554:     public function getSearchKeyword($number) {
    + 555: 
    + 556:         $this->errorReset();
    + 557: 
    + 558:         if (!InputValidator::isRangedInt($number, 1, $this->getNumberOfSearchKeywords())) {
    + 559:             $this->errorSet("P-9");
    + 560:             return;
    + 561:         }
    + 562:         return $this->searchKeywords[$number - 1];
    + 563:     }
    + 564: 
    + 565:     /**
    + 566:      * Returns the short description.
    + 567:      *
    + 568:      * @author David Pauli <contact@david-pauli.de>
    + 569:      * @return String The short description.
    + 570:      * @since 0.0.0
    + 571:      * @since 0.1.0 Use a default Locale.
    + 572:      * @since 0.1.1 Fix to call function without locale parameter.
    + 573:      * @since 0.1.2 Add error reporting.
    + 574:      */
    + 575:     public function getShortDescription() {
    + 576: 
    + 577:         $this->errorReset();
    + 578: 
    + 579:         return $this->shortDescription;
    + 580:     }
    + 581: 
    + 582:     /**
    + 583:      * Returns the slideshow.
    + 584:      *
    + 585:      * @author David Pauli <contact@david-pauli.de>
    + 586:      * @return ProductSlideshow Gets the product slideshow.
    + 587:      * @since 0.1.0
    + 588:      * @since 0.1.1 Slideshows are not reloadable since now.
    + 589:      * @since 0.1.2 Add error reporting.
    + 590:      */
    + 591:     public function getSlideshow() {
    + 592: 
    + 593:         $this->errorReset();
    + 594: 
    + 595:         // if the slideshow is not loaded until now
    + 596:         if (InputValidator::isEmpty($this->slideshow)) {
    + 597: 
    + 598:             $this->slideshow = new ProductSlideshow($this->productID);
    + 599:         }
    + 600: 
    + 601:         return $this->slideshow;
    + 602:     }
    + 603: 
    + 604:     /**
    + 605:      * Returns the small image.
    + 606:      *
    + 607:      * @author David Pauli <contact@david-pauli.de>
    + 608:      * @return Image The small image.
    + 609:      * @since 0.0.0
    + 610:      * @since 0.1.2 Add error reporting.
    + 611:      */
    + 612:     public function getSmallImage() {
    + 613: 
    + 614:         $this->errorReset();
    + 615: 
    + 616:         return !InputValidator::isEmptyArrayKey($this->images, "Small") ? $this->images["Small"] : null;
    + 617:     }
    + 618: 
    + 619:     /**
    + 620:      * Returns the stock level.
    + 621:      *
    + 622:      * @author David Pauli <contact@david-pauli.de>
    + 623:      * @return float|null The stock level of the product.
    + 624:      * @since 0.1.0
    + 625:      * @since 0.1.1 Unstatic every attributes.
    + 626:      * @since 0.1.2 Add error reporting.
    + 627:      */
    + 628:     public function getStockLevel() {
    + 629: 
    + 630:         $this->errorReset();
    + 631: 
    + 632:         $timestamp = (int) (microtime(true) * 1000);
    + 633: 
    + 634:         // if the attribute is not loaded until now
    + 635:         if (InputValidator::isEmpty($this->stockLevel) ||
    + 636:             $this->NEXT_REQUEST_TIMESTAMP < $timestamp) {
    + 637: 
    + 638:             $this->loadStockLevel();
    + 639:         }
    + 640: 
    + 641:         return $this->stockLevel;
    + 642:     }
    + 643: 
    + 644:     /**
    + 645:      * Returns the UPC.
    + 646:      *
    + 647:      * @author David Pauli <contact@david-pauli.de>
    + 648:      * @return String Gets the UPC.
    + 649:      * @since 0.1.2
    + 650:      */
    + 651:     public function getUPC() {
    + 652: 
    + 653:         $this->errorReset();
    + 654: 
    + 655:         return $this->UPC;
    + 656:     }
    + 657: 
    + 658:     /**
    + 659:      * Returns the with deposit price.
    + 660:      *
    + 661:      * @author David Pauli <contact@david-pauli.de>
    + 662:      * @return ProductPrice Gets the with deposit price.
    + 663:      * @since 0.1.0
    + 664:      * @since 0.1.2 Add error reporting.
    + 665:      */
    + 666:     public function getWithDepositPrice() {
    + 667: 
    + 668:         $this->errorReset();
    + 669: 
    + 670:         return $this->withDepositPrice;
    + 671:     }
    + 672: 
    + 673:     /**
    + 674:      * Increases the stock level.
    + 675:      *
    + 676:      * @author David Pauli <contact@david-pauli.de>
    + 677:      * @param float $step The value the stock level should be increased, default value is 1.
    + 678:      * @return float|null The new stock level of the product.
    + 679:      * @since 0.1.0
    + 680:      * @since 0.1.2 Add error reporting.
    + 681:      */
    + 682:     public function increaseStockLevel($step = 1.0) {
    + 683: 
    + 684:         $this->errorReset();
    + 685: 
    + 686:         $this->getStockLevel();
    + 687: 
    + 688:         // cast int to float
    + 689:         if (InputValidator::isInt($step)) {
    + 690: 
    + 691:             $step = (float) $step;
    + 692:         }
    + 693: 
    + 694:         if (!InputValidator::isRangedFloat($step, 0.0)) {
    + 695: 
    + 696:             return $this->stockLevel;
    + 697:         }
    + 698: 
    + 699:         $this->changeStockLevel((float) $step);
    + 700: 
    + 701:         return $this->stockLevel;
    + 702:     }
    + 703: 
    + 704:     /**
    + 705:      * Returns true if it is for sale.
    + 706:      *
    + 707:      * @author David Pauli <contact@david-pauli.de>
    + 708:      * @return boolean True if it is for sale, false if not.
    + 709:      * @since 0.0.0
    + 710:      * @since 0.1.2 Add error reporting.
    + 711:      */
    + 712:     public function isForSale() {
    + 713: 
    + 714:         $this->errorReset();
    + 715: 
    + 716:         return $this->forSale;
    + 717:     }
    + 718: 
    + 719:     /**
    + 720:      * Returns true if it is a special offer.
    + 721:      *
    + 722:      * @author David Pauli <contact@david-pauli.de>
    + 723:      * @return boolean True if it is a special offer, false if not.
    + 724:      * @since 0.0.0
    + 725:      * @since 0.1.2 Add error reporting.
    + 726:      */
    + 727:     public function isSpecialOffer() {
    + 728: 
    + 729:         $this->errorReset();
    + 730: 
    + 731:         return $this->specialOffer;
    + 732:     }
    + 733: 
    + 734:     /**
    + 735:      * Sets the description of the product.
    + 736:      *
    + 737:      * @author David Pauli <contact@david-pauli.de>
    + 738:      * @param String $description The new description.
    + 739:      * @since 0.1.2
    + 740:      */
    + 741:     public function setDescription($description) {
    + 742: 
    + 743:         $this->errorReset();
    + 744: 
    + 745:         self::setAttribute("/description", $dscription);
    + 746:     }
    + 747: 
    + 748:     /**
    + 749:      * Sets the EAN of the product.
    + 750:      *
    + 751:      * @author David Pauli <contact@david-pauli.de>
    + 752:      * @param String $ean The new EAN.
    + 753:      * @since 0.1.2
    + 754:      */
    + 755:     public function setEAN($ean) {
    + 756: 
    + 757:         $this->errorReset();
    + 758: 
    + 759:         self::setAttribute("/ean", $ean);
    + 760:     }
    + 761: 
    + 762:     /**
    + 763:      * Sets the energy labels string of the product.
    + 764:      *
    + 765:      * @author David Pauli <contact@david-pauli.de>
    + 766:      * @param String $energyLabelsString The new energy labels string.
    + 767:      * @since 0.1.2
    + 768:      */
    + 769:     public function setEnergyLabelsString($energyLabelsString) {
    + 770: 
    + 771:         $this->errorReset();
    + 772: 
    + 773:         self::setAttribute("/energyLabelsString", $energyLabelsString);
    + 774:     }
    + 775: 
    + 776:     /**
    + 777:      * Sets the essential features of the product.
    + 778:      *
    + 779:      * @author David Pauli <contact@david-pauli.de>
    + 780:      * @param String $essentialFeatures The new essential features.
    + 781:      * @since 0.1.2
    + 782:      */
    + 783:     public function setEssentialFeatures($essentialFeatures) {
    + 784: 
    + 785:         $this->errorReset();
    + 786: 
    + 787:         self::setAttribute("/essentialFeatures", $essentialFeatures);
    + 788:     }
    + 789: 
    + 790:     /**
    + 791:      * Sets the manufacturer of the product.
    + 792:      *
    + 793:      * @author David Pauli <contact@david-pauli.de>
    + 794:      * @param String $manufacturer The new manufacturer.
    + 795:      * @since 0.1.2
    + 796:      */
    + 797:     public function setManufacturer($manufacturer) {
    + 798: 
    + 799:         $this->errorReset();
    + 800: 
    + 801:         self::setAttribute("/manufacturer", $manufacturer);
    + 802:     }
    + 803: 
    + 804:     /**
    + 805:      * Sets the name of the product.
    + 806:      *
    + 807:      * @author David Pauli <contact@david-pauli.de>
    + 808:      * @param String $name The new name.
    + 809:      * @since 0.1.2
    + 810:      */
    + 811:     public function setName($name) {
    + 812: 
    + 813:         $this->errorReset();
    + 814: 
    + 815:         self::setAttribute("/name", $name);
    + 816:     }
    + 817: 
    + 818:     /**
    + 819:      * Sets the product number of the product.
    + 820:      *
    + 821:      * @author David Pauli <contact@david-pauli.de>
    + 822:      * @param String $number The new product number.
    + 823:      * @since 0.1.2
    + 824:      */
    + 825:     public function setNumber($number) {
    + 826: 
    + 827:         $this->errorReset();
    + 828: 
    + 829:         self::setAttribute("/productNumber", $number);
    + 830:     }
    + 831: 
    + 832:     /**
    + 833:      * Sets the search keywords of the product.
    + 834:      *
    + 835:      * @author David Pauli <contact@david-pauli.de>
    + 836:      * @param String $searchKeywords The new $search keywords.
    + 837:      * @since 0.1.2
    + 838:      */
    + 839:     public function setSearchKeywords($searchKeywords) {
    + 840: 
    + 841:         $this->errorReset();
    + 842: 
    + 843:         self::setAttribute("/searchKeywords", $searchKeywords);
    + 844:     }
    + 845: 
    + 846:     /**
    + 847:      * Sets the short description of the product.
    + 848:      *
    + 849:      * @author David Pauli <contact@david-pauli.de>
    + 850:      * @param String $shortDescription The new short description.
    + 851:      * @since 0.1.2
    + 852:      */
    + 853:     public function setShortDescription($shortDescription) {
    + 854: 
    + 855:         $this->errorReset();
    + 856: 
    + 857:         self::setAttribute("/shortDescription", $shortDescription);
    + 858:     }
    + 859: 
    + 860:     /**
    + 861:      * Sets the UPC of the product.
    + 862:      *
    + 863:      * @author David Pauli <contact@david-pauli.de>
    + 864:      * @param String $upc The new UPC.
    + 865:      * @since 0.1.2
    + 866:      */
    + 867:     public function setUPC($upc) {
    + 868: 
    + 869:         $this->errorReset();
    + 870: 
    + 871:         self::setAttribute("/upc", $upc);
    + 872:     }
    + 873: 
    + 874:     /**
    + 875:      * Deletes the description value of the product.
    + 876:      *
    + 877:      * @author David Pauli <contact@david-pauli.de>
    + 878:      * @since 0.1.2
    + 879:      */
    + 880:     public function unsetDescription() {
    + 881: 
    + 882:         $this->errorReset();
    + 883: 
    + 884:         self::unsetAttribute("/description");
    + 885:     }
    + 886: 
    + 887:     /**
    + 888:      * Deletes the EAN value of the product.
    + 889:      *
    + 890:      * @author David Pauli <contact@david-pauli.de>
    + 891:      * @since 0.1.2
    + 892:      */
    + 893:     public function unsetEAN() {
    + 894: 
    + 895:         $this->errorReset();
    + 896: 
    + 897:         self::unsetAttribute("/ean");
    + 898:     }
    + 899: 
    + 900:     /**
    + 901:      * Deletes the energy labels string value of the product.
    + 902:      *
    + 903:      * @author David Pauli <contact@david-pauli.de>
    + 904:      * @since 0.1.2
    + 905:      */
    + 906:     public function unsetEnergyLabelsString() {
    + 907: 
    + 908:         $this->errorReset();
    + 909: 
    + 910:         self::unsetAttribute("/energyLabelsString");
    + 911:     }
    + 912: 
    + 913:     /**
    + 914:      * Deletes the essential features value of the product.
    + 915:      *
    + 916:      * @author David Pauli <contact@david-pauli.de>
    + 917:      * @since 0.1.2
    + 918:      */
    + 919:     public function unsetEssentialFeatures() {
    + 920: 
    + 921:         $this->errorReset();
    + 922: 
    + 923:         self::unsetAttribute("/essentialFeatures");
    + 924:     }
    + 925: 
    + 926:     /**
    + 927:      * Deletes the manufacturer value of the product.
    + 928:      *
    + 929:      * @author David Pauli <contact@david-pauli.de>
    + 930:      * @since 0.1.2
    + 931:      */
    + 932:     public function unsetManufacturer() {
    + 933: 
    + 934:         $this->errorReset();
    + 935: 
    + 936:         self::unsetAttribute("/manufacturer");
    + 937:     }
    + 938: 
    + 939:     /**
    + 940:      * Deletes the name value of the product.
    + 941:      *
    + 942:      * @author David Pauli <contact@david-pauli.de>
    + 943:      * @since 0.1.2
    + 944:      */
    + 945:     public function unsetName() {
    + 946: 
    + 947:         $this->errorReset();
    + 948: 
    + 949:         self::unsetAttribute("/name");
    + 950:     }
    + 951: 
    + 952:     /**
    + 953:      * Deletes the search keywords of the product.
    + 954:      *
    + 955:      * @author David Pauli <contact@david-pauli.de>
    + 956:      * @since 0.1.2
    + 957:      */
    + 958:     public function unsetSearchKeywords() {
    + 959: 
    + 960:         $this->errorReset();
    + 961: 
    + 962:         self::unsetAttribute("/searchKeywords");
    + 963:     }
    + 964: 
    + 965:     /**
    + 966:      * Deletes the short description value of the product.
    + 967:      *
    + 968:      * @author David Pauli <contact@david-pauli.de>
    + 969:      * @since 0.1.2
    + 970:      */
    + 971:     public function unsetShortDescription() {
    + 972: 
    + 973:         $this->errorReset();
    + 974: 
    + 975:         self::unsetAttribute("/shortDescription");
    + 976:     }
    + 977: 
    + 978:     /**
    + 979:      * Deletes the UPC value of the product.
    + 980:      *
    + 981:      * @author David Pauli <contact@david-pauli.de>
    + 982:      * @since 0.1.2
    + 983:      */
    + 984:     public function unsetUPC() {
    + 985: 
    + 986:         $this->errorReset();
    + 987: 
    + 988:         self::unsetAttribute("/upc");
    + 989:     }
    + 990: 
    + 991:     /**
    + 992:      * Change the stock level with a step.
    + 993:      *
    + 994:      * @author David Pauli <contact@david-pauli.de>
    + 995:      * @since 0.1.0
    + 996:      * @since 0.1.1 Unstatic every attributes.
    + 997:      * @since 0.1.2 Add error reporting.
    + 998:      * @param float $step The step to change.
    + 999:      */
    +1000:     private function changeStockLevel($step) {
    +1001: 
    +1002:         // if parameter is wrong or GET is blocked
    +1003:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::PUT)) {
    +1004: 
    +1005:             $this->errorSet("RESTC-9");
    +1006:             return;
    +1007:         }
    +1008: 
    +1009:         if (!InputValidator::isFloat($step)) {
    +1010: 
    +1011:             $this->errorSet("P-8");
    +1012:             Logger::error("The " . $step . " step to change the stocklevel is no float.");
    +1013:             return;
    +1014:         }
    +1015: 
    +1016:         $postfields = array("changeStocklevel" => $step);
    +1017:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL, $postfields);
    +1018: 
    +1019:         // if respond is empty
    +1020:         if (InputValidator::isEmpty($content)) {
    +1021: 
    +1022:             $this->errorSet("P-6");
    +1023:             return;
    +1024:         }
    +1025: 
    +1026:         // if there are no items
    +1027:         if (InputValidator::isEmptyArrayKey($content, "stocklevel")) {
    +1028: 
    +1029:             $this->errorSet("P-7");
    +1030:             Logger::error("Respond for " . self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL . " can not be interpreted.");
    +1031:             return;
    +1032:         }
    +1033: 
    +1034:         $this->stockLevel = (float) $content["stocklevel"];
    +1035: 
    +1036:         // update timestamp when make the next request
    +1037:         $timestamp = (int) (microtime(true) * 1000);
    +1038:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    +1039:     }
    +1040: 
    +1041:     /**
    +1042:      * Loads the product.
    +1043:      *
    +1044:      * @author David Pauli <contact@david-pauli.de>
    +1045:      * @param Array $product The product in an array.
    +1046:      * @since 0.1.2
    +1047:      */
    +1048:     private function load($productParameter) {
    +1049: 
    +1050:         // if the product comes from the shop API
    +1051:         if (InputValidator::isArray($productParameter) &&
    +1052:             !InputValidator::isEmptyArrayKey($productParameter, "productId")) {
    +1053: 
    +1054:             $this->productID = $productParameter['productId'];
    +1055: 
    +1056:             // load locale depended content
    +1057:             if (!InputValidator::isEmptyArrayKey($productParameter, "forSale")) {
    +1058: 
    +1059:                 $this->forSale = $productParameter['forSale'];
    +1060:             }
    +1061: 
    +1062:             if (!InputValidator::isEmptyArrayKey($productParameter, "specialOffer")) {
    +1063: 
    +1064:                 $this->specialOffer = $productParameter['specialOffer'];
    +1065:             }
    +1066: 
    +1067:             if (!InputValidator::isEmptyArrayKey($productParameter, "name")) {
    +1068: 
    +1069:                 $this->name = $productParameter['name'];
    +1070:             }
    +1071: 
    +1072:             if (!InputValidator::isEmptyArrayKey($productParameter, "shortDescription")) {
    +1073: 
    +1074:                 $this->shortDescription = $productParameter['shortDescription'];
    +1075:             }
    +1076: 
    +1077:             if (!InputValidator::isEmptyArrayKey($productParameter, "description")) {
    +1078: 
    +1079:                 $this->description = $productParameter['description'];
    +1080:             }
    +1081: 
    +1082:             if (!InputValidator::isEmptyArrayKey($productParameter, "availabilityText")) {
    +1083: 
    +1084:                 $this->availabilityText = $productParameter['availabilityText'];
    +1085:             }
    +1086: 
    +1087:             if (!InputValidator::isEmptyArrayKey($productParameter, "productNumber")) {
    +1088: 
    +1089:                 $this->productNumber = $productParameter['productNumber'];
    +1090:             }
    +1091: 
    +1092:             if (!InputValidator::isEmptyArrayKey($productParameter, "energyLabelsString")) {
    +1093: 
    +1094:                 $this->energyLabelsString = $productParameter['energyLabelsString'];
    +1095:             }
    +1096: 
    +1097:             if (!InputValidator::isEmptyArrayKey($productParameter, "manufacturer")) {
    +1098: 
    +1099:                 $this->manufacturer = $productParameter['manufacturer'];
    +1100:             }
    +1101: 
    +1102:             if (!InputValidator::isEmptyArrayKey($productParameter, "upc")) {
    +1103: 
    +1104:                 $this->UPC = $productParameter['upc'];
    +1105:             }
    +1106: 
    +1107:             if (!InputValidator::isEmptyArrayKey($productParameter, "ean")) {
    +1108: 
    +1109:                 $this->EAN = $productParameter['ean'];
    +1110:             }
    +1111: 
    +1112:             if (!InputValidator::isEmptyArrayKey($productParameter, "essentialFeatures")) {
    +1113: 
    +1114:                 $this->essentialFeatures = $productParameter['essentialFeatures'];
    +1115:             }
    +1116: 
    +1117:             if (!InputValidator::isEmptyArrayKey($productParameter, "searchKeywords")) {
    +1118: 
    +1119:                 $this->searchKeywords = $productParameter['searchKeywords'];
    +1120:             }
    +1121: 
    +1122:             // parse images
    +1123:             if (!InputValidator::isEmptyArrayKey($productParameter, "images")) {
    +1124: 
    +1125:                 foreach ($productParameter['images'] as $image) {
    +1126: 
    +1127:                     if (InputValidator::isArray($image) &&
    +1128:                         !InputValidator::isEmptyArrayKey($image, "classifier") &&
    +1129:                         !InputValidator::isEmptyArrayKey($image, "url")) {
    +1130: 
    +1131:                         $this->images[$image['classifier']] = new Image($image['url']);
    +1132:                     }
    +1133:                 }
    +1134:             }
    +1135: 
    +1136:             // parse price
    +1137:             if (!InputValidator::isEmptyArrayKey($productParameter, "priceInfo")) {
    +1138: 
    +1139:                 $priceInformation = $productParameter['priceInfo'];
    +1140: 
    +1141:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "price") &&
    +1142:                     !InputValidator::isEmptyArrayKey($priceInformation, "quantity")) {
    +1143: 
    +1144:                     $this->price = new ProductPriceWithQuantity($this->productID, ProductPriceType::PRICE, $priceInformation['price'], $priceInformation['quantity']);
    +1145:                 }
    +1146: 
    +1147:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "depositPrice")) {
    +1148: 
    +1149:                     $this->depositPrice = new ProductPrice($this->productID, ProductPriceType::DEPOSIT, $priceInformation['depositPrice']);
    +1150:                 }
    +1151: 
    +1152:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "ecoParticipationPrice")) {
    +1153: 
    +1154:                     $this->ecoParticipationPrice = new ProductPrice($this->productID, ProductPriceType::ECOPARTICIPATION, $priceInformation['ecoParticipationPrice']);
    +1155:                 }
    +1156: 
    +1157:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "priceWithDeposits")) {
    +1158: 
    +1159:                     $this->withDepositPrice = new ProductPrice($this->productID, ProductPriceType::WITHDEPOSITS, $priceInformation['priceWithDeposits']);
    +1160:                 }
    +1161: 
    +1162:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "manufacturerPrice")) {
    +1163: 
    +1164:                     $this->manufacturerPrice = new ProductPrice($this->productID, ProductPriceType::MANUFACTURER, $priceInformation['manufacturerPrice']);
    +1165:                 }
    +1166: 
    +1167:                 if (!InputValidator::isEmptyArrayKey($priceInformation, "basePrice")) {
    +1168: 
    +1169:                     $this->basePrice = new ProductPrice($this->productID, ProductPriceType::BASE, $priceInformation['basePrice']);
    +1170:                 }
    +1171:             }
    +1172:         }
    +1173:     }
    +1174: 
    +1175:     /**
    +1176:      * Loads the product attributes.
    +1177:      *
    +1178:      * @author David Pauli <contact@david-pauli.de>
    +1179:      * @since 0.1.0
    +1180:      * @since 0.1.1 Unstatic every attributes.
    +1181:      * @since 0.1.2 Add error reporting.
    +1182:      */
    +1183:     private function loadAttributes() {
    +1184: 
    +1185:         // if parameter is wrong or GET is blocked
    +1186:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
    +1187: 
    +1188:             $this->errorSet("RESTC-9");
    +1189:             return;
    +1190:         }
    +1191: 
    +1192:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_ATTRIBUTES);
    +1193: 
    +1194:         // if respond is empty
    +1195:         if (InputValidator::isEmpty($content)) {
    +1196: 
    +1197:             $this->errorSet("P-4");
    +1198:             return;
    +1199:         }
    +1200: 
    +1201:         // if there are no items
    +1202:         if (InputValidator::isEmptyArrayKey($content, "items")) {
    +1203: 
    +1204:             $this->errorSet("P-5");
    +1205:             Logger::error("Respond for " . self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_ATTRIBUTES . " can not be interpreted.");
    +1206:             return;
    +1207:         }
    +1208: 
    +1209:         // is there any attribute found: load the attribute.
    +1210:         foreach ($content['items'] as $number => $attribute) {
    +1211: 
    +1212:             // parse every attribute
    +1213:             $this->attributes[$number] = new ProductAttribute($attribute);
    +1214:         }
    +1215: 
    +1216:         // update timestamp when make the next request
    +1217:         $timestamp = (int) (microtime(true) * 1000);
    +1218:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    +1219:     }
    +1220: 
    +1221:     /**
    +1222:      * Loads the stock level.
    +1223:      *
    +1224:      * @author David Pauli <contact@david-pauli.de>
    +1225:      * @since 0.1.0
    +1226:      * @since 0.1.1 Unstatic every attributes.
    +1227:      * @since 0.1.2 Add error reporting.
    +1228:      */
    +1229:     private function loadStockLevel() {
    +1230: 
    +1231:         // if parameter is wrong or GET is blocked
    +1232:         if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
    +1233: 
    +1234:             $this->errorSet("RESTC-9");
    +1235:             return;
    +1236:         }
    +1237: 
    +1238:         $content = RESTClient::send(self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL);
    +1239: 
    +1240:         // if respond is empty
    +1241:         if (InputValidator::isEmpty($content)) {
    +1242: 
    +1243:             $this->errorSet("P-6");
    +1244:             return;
    +1245:         }
    +1246: 
    +1247:         // if there are no items
    +1248:         if (InputValidator::isEmptyArrayKey($content, "stocklevel")) {
    +1249: 
    +1250:             $this->errorSet("P-7");
    +1251:             Logger::error("Respond for " . self::RESTPATH . "/" . $this->productID . "/" .  self::RESTPATH_STOCKLEVEL . " can not be interpreted.");
    +1252:             return;
    +1253:         }
    +1254: 
    +1255:         $this->stockLevel = (float) $content["stocklevel"];
    +1256: 
    +1257:         // update timestamp when make the next request
    +1258:         $timestamp = (int) (microtime(true) * 1000);
    +1259:         $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
    +1260:     }
    +1261: 
    +1262:     /**
    +1263:      * Sets an attribute of the product.
    +1264:      *
    +1265:      * @author David Pauli <contact@david-pauli.de>
    +1266:      * @param String $path The path to this attribute.
    +1267:      * @param String $value The new attribute value.
    +1268:      * @since 0.1.2
    +1269:      */
    +1270:     private function setAttribute($path, $value) {
    +1271: 
    +1272:         // if parameter is no string or
    +1273:         if (!InputValidator::isString($value)) {
    +1274: 
    +1275:             Logger::warning("ep6\Product\nNew attribute (" . $value . ") is no string.");
    +1276:             $this->errorSet("P-2");
    +1277:             return;
    +1278:         }
    +1279: 
    +1280:         // if PATCH does not work
    +1281:         if (!RESTClient::setRequestMethod("PATCH")) {
    +1282: 
    +1283:             $this->errorSet("RESTC-9");
    +1284:             return;
    +1285:         }
    +1286: 
    +1287:         $parameter = array("op" => "add", "path" => $path, "value" => $value);
    +1288:         $productParameter = RESTClient::send(self::RESTPATH . "/" . $this->productID, $parameter);
    +1289: 
    +1290:         // update the product
    +1291:         self::load($productParameter);
    +1292:     }
    +1293: 
    +1294:     /**
    +1295:      * Unsets an attribute value of the product.
    +1296:      *
    +1297:      * @author David Pauli <contact@david-pauli.de>
    +1298:      * @param String $path The path to this attribute.
    +1299:      * @since 0.1.2
    +1300:      */
    +1301:     private function unsetAttribute($path) {
    +1302: 
    +1303:         // if PATCH does not work
    +1304:         if (!RESTClient::setRequestMethod("PATCH")) {
    +1305: 
    +1306:             $this->errorSet("RESTC-9");
    +1307:             return;
    +1308:         }
    +1309: 
    +1310:         $parameter = array("op" => "remove", "path" => $path);
    +1311:         $productParameter = RESTClient::send(self::RESTPATH, $parameter);
    +1312: 
    +1313:         // update the product
    +1314:         self::load($productParameter);
    +1315:     }
    +1316: }
    +1317: ?>
    - + diff --git a/doc/source-class-ep6.ProductAttribute.html b/doc/source-class-ep6.ProductAttribute.html index e389aa1..baa7bba 100644 --- a/doc/source-class-ep6.ProductAttribute.html +++ b/doc/source-class-ep6.ProductAttribute.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,158 +101,160 @@

    Traits

      1: <?php
       2: /**
    -  3:  * This file represents the product attribute class.
    +  3:  * This file represents the Product Attribute class.
       4:  *
       5:  * @author David Pauli <contact@david-pauli.de>
       6:  * @since 0.1.0
       7:  */
       8: namespace ep6;
       9: /**
    - 10:  * This is the product attribute class which saves all attributes of a product.
    + 10:  * This is the Product Attribute class which saves all attributes of a product.
      11:  *
      12:  * @author David Pauli <contact@david-pauli.de>
    - 13:  * @since 0.1.0
    - 14:  * @since 0.1.1 The object can be echoed.
    - 15:  * @api
    - 16:  * @package ep6
    - 17:  * @subpackage Shopobjects\Product
    - 18:  */
    - 19: class ProductAttribute {
    - 20: 
    - 21:     /** @var String|null The intern name of this attribute. */
    - 22:     private $internName = null;
    - 23: 
    - 24:     /** @var String|null The written name of this attribute. */
    - 25:     private $name = null;
    - 26: 
    - 27:     /** @var boolean Can only be set one value. */
    - 28:     private $oneValue = false;
    - 29: 
    - 30:     /** @var String|null The type of the product attribute value. */
    - 31:     private $type = null;
    - 32: 
    - 33:     /** @var String[] Space for saving the possible attribute values. */
    - 34:     private $values = array();
    - 35: 
    - 36:     /**
    - 37:      * This function gets the product attributes.
    - 38:      *
    - 39:      * @author David Pauli <contact@david-pauli.de>
    + 13:  * @package ep6
    + 14:  * @since 0.1.0
    + 15:  * @since 0.1.1 The object can be echoed.
    + 16:  * @subpackage Shopobjects\Product
    + 17:  */
    + 18: class ProductAttribute {
    + 19: 
    + 20:     /** @var String|null The intern name of this attribute. */
    + 21:     private $internName = null;
    + 22: 
    + 23:     /** @var String|null The written name of this attribute. */
    + 24:     private $name = null;
    + 25: 
    + 26:     /** @var boolean Can only be set one value. */
    + 27:     private $oneValue = false;
    + 28: 
    + 29:     /** @var String|null The type of the product attribute value. */
    + 30:     private $type = null;
    + 31: 
    + 32:     /** @var String[] Space for saving the possible attribute values. */
    + 33:     private $values = array();
    + 34: 
    + 35:     /**
    + 36:      * This function gets the product attributes.
    + 37:      *
    + 38:      * @author David Pauli <contact@david-pauli.de>
    + 39:      * @param mixed[] $attribute The attribute in an array.
      40:      * @since 0.1.0
    - 41:      * @api
    - 42:      * @param mixed[] $attribute The attribute in an array.
    - 43:      */
    - 44:     public function __construct($attribute) {
    + 41:      */
    + 42:     public function __construct($attribute) {
    + 43: 
    + 44:         if (!InputValidator::isEmptyArrayKey($attribute, "key")) {
      45: 
    - 46:         if (!InputValidator::isEmptyArrayKey($attribute, "key")) {
    - 47:             $this->internName = $attribute["key"];
    - 48:         }
    + 46:             $this->internName = $attribute["key"];
    + 47:         }
    + 48: 
      49:         if (!InputValidator::isEmptyArrayKey($attribute, "displayKey")) {
    - 50:             $this->name = $attribute["displayKey"];
    - 51:         }
    - 52:         if (!InputValidator::isEmptyArrayKey($attribute, "singleValue")) {
    - 53:             $this->oneValue = $attribute["singleValue"];
    - 54:         }
    - 55:         if (!InputValidator::isEmptyArrayKey($attribute, "type")) {
    - 56:             $this->type = $attribute["type"];
    + 50: 
    + 51:             $this->name = $attribute["displayKey"];
    + 52:         }
    + 53: 
    + 54:         if (!InputValidator::isEmptyArrayKey($attribute, "singleValue")) {
    + 55: 
    + 56:             $this->oneValue = $attribute["singleValue"];
      57:         }
      58: 
    - 59:         if (!InputValidator::isEmptyArrayKey($attribute, "type") &&
    - 60:             !InputValidator::isArray($attribute["values"])) {
    - 61: 
    - 62:             foreach ($attribute["values"] as $key => $value) {
    - 63:                 if (!InputValidator::isEmptyArrayKey($value, "value") &&
    - 64:                     !InputValidator::isEmptyArrayKey($value, "displayValue")) {
    - 65:                     $this->values[$value["value"]] = $value["displayValue"];
    - 66:                 }
    - 67:             }
    - 68:         }
    - 69:     }
    - 70: 
    - 71:     /**
    - 72:      * Returns the intern name of the attribute.
    - 73:      *
    - 74:      * @author David Pauli <contact@david-pauli.de>
    - 75:      * @since 0.1.0
    - 76:      * @api
    - 77:      * @return String|null The intern name of the attribute.
    - 78:      */
    - 79:     public function getInternName() {
    - 80: 
    - 81:         return $this->internName;
    - 82:     }
    - 83: 
    - 84:     /**
    - 85:      * Returns the name of the attribute.
    - 86:      *
    - 87:      * @author David Pauli <contact@david-pauli.de>
    - 88:      * @since 0.1.0
    - 89:      * @api
    - 90:      * @return String|null The name of the attribute.
    - 91:      */
    - 92:     public function getName() {
    - 93: 
    - 94:         return $this->name;
    - 95:     }
    - 96: 
    - 97:     /**
    - 98:      * Returns whether the attribute can one has one value.
    - 99:      *
    -100:      * @author David Pauli <contact@david-pauli.de>
    + 59:         if (!InputValidator::isEmptyArrayKey($attribute, "type")) {
    + 60: 
    + 61:             $this->type = $attribute["type"];
    + 62:         }
    + 63: 
    + 64:         if (!InputValidator::isEmptyArrayKey($attribute, "type") &&
    + 65:             !InputValidator::isArray($attribute["values"])) {
    + 66: 
    + 67:             foreach ($attribute["values"] as $key => $value) {
    + 68: 
    + 69:                 if (!InputValidator::isEmptyArrayKey($value, "value") &&
    + 70:                     !InputValidator::isEmptyArrayKey($value, "displayValue")) {
    + 71: 
    + 72:                     $this->values[$value["value"]] = $value["displayValue"];
    + 73:                 }
    + 74:             }
    + 75:         }
    + 76:     }
    + 77: 
    + 78:     /**
    + 79:      * Prints the Product attribute object as a string.
    + 80:      *
    + 81:      * This function returns the setted values of the Product attribute object.
    + 82:      *
    + 83:      * @author David Pauli <contact@david-pauli.de>
    + 84:      * @return String The Product attribute as a string.
    + 85:      * @since 0.1.1
    + 86:      */
    + 87:     public function __toString() {
    + 88: 
    + 89:         return "<strong>Internal name:</strong> " . $this->internName . "<br/>" .
    + 90:                 "<strong>Name:</strong> " . $this->name . "<br/>" .
    + 91:                 "<strong>Can have only one value:</strong> " . $this->oneValue . "<br/>" .
    + 92:                 "<strong>Value type:</strong> " . $this->type . "<br/>" .
    + 93:                 "<strong>Values:</strong> " . print_r($this->values) . "<br/>";
    + 94:     }
    + 95: 
    + 96:     /**
    + 97:      * Returns the intern name of the attribute.
    + 98:      *
    + 99:      * @author David Pauli <contact@david-pauli.de>
    +100:      * @return String|null The intern name of the attribute.
     101:      * @since 0.1.0
    -102:      * @api
    -103:      * @return boolean True, if the attribute can only have one value.
    -104:      */
    -105:     public function isOneValue() {
    -106: 
    -107:         return $this->isOneValue;
    -108:     }
    -109: 
    -110:     /**
    -111:      * Returns the type of the attribute value.
    -112:      *
    -113:      * @author David Pauli <contact@david-pauli.de>
    -114:      * @since 0.1.0
    -115:      * @api
    -116:      * @return String|null The type of the attribute value, like String or int.
    -117:      */
    -118:     public function getType() {
    +102:      */
    +103:     public function getInternName() {
    +104: 
    +105:         return $this->internName;
    +106:     }
    +107: 
    +108:     /**
    +109:      * Returns the name of the attribute.
    +110:      *
    +111:      * @author David Pauli <contact@david-pauli.de>
    +112:      * @return String|null The name of the attribute.
    +113:      * @since 0.1.0
    +114:      */
    +115:     public function getName() {
    +116: 
    +117:         return $this->name;
    +118:     }
     119: 
    -120:         return $this->type;
    -121:     }
    -122: 
    -123:     /**
    -124:      * Returns the possible values of this attribute.
    -125:      *
    -126:      * @author David Pauli <contact@david-pauli.de>
    -127:      * @since 0.1.0
    -128:      * @api
    -129:      * @return String[] Array of possible values of this attribute.
    -130:      */
    -131:     public function getValues() {
    -132: 
    -133:         return $this->values;
    -134:     }
    -135: 
    -136:     /**
    -137:      * Prints the Product attribute object as a string.
    -138:      *
    -139:      * This function returns the setted values of the Product attribute object.
    -140:      *
    -141:      * @author David Pauli <contact@david-pauli.de>
    -142:      * @since 0.1.1
    -143:      * @return String The Product attribute as a string.
    -144:      */
    -145:     public function __toString() {
    -146: 
    -147:         return "<strong>Internal name:</strong> " . $this->internName . "<br/>" .
    -148:                 "<strong>Name:</strong> " . $this->name . "<br/>" .
    -149:                 "<strong>Can have only one value:</strong> " . $this->oneValue . "<br/>" .
    -150:                 "<strong>Value type:</strong> " . $this->type . "<br/>" .
    -151:                 "<strong>Values:</strong> " . print_r($this->values) . "<br/>";
    -152:     }
    -153: }
    -154: ?>
    +120: /** +121: * Returns the type of the attribute value. +122: * +123: * @author David Pauli <contact@david-pauli.de> +124: * @return String|null The type of the attribute value, like String or int. +125: * @since 0.1.0 +126: */ +127: public function getType() { +128: +129: return $this->type; +130: } +131: +132: /** +133: * Returns the possible values of this attribute. +134: * +135: * @author David Pauli <contact@david-pauli.de> +136: * @return String[] Array of possible values of this attribute. +137: * @since 0.1.0 +138: */ +139: public function getValues() { +140: +141: return $this->values; +142: } +143: +144: /** +145: * Returns whether the attribute can one has one value. +146: * +147: * @author David Pauli <contact@david-pauli.de> +148: * @return boolean True, if the attribute can only have one value. +149: * @since 0.1.0 +150: */ +151: public function isOneValue() { +152: +153: return $this->isOneValue; +154: } +155: } +156: ?> - + diff --git a/doc/source-class-ep6.ProductFilter.html b/doc/source-class-ep6.ProductFilter.html index 9a7bf38..0c27018 100644 --- a/doc/source-class-ep6.ProductFilter.html +++ b/doc/source-class-ep6.ProductFilter.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -107,541 +111,582 @@

    Traits

    10: * This is a product filter class to search products via the REST call "product". 11: * 12: * @author David Pauli <contact@david-pauli.de> - 13: * @since 0.0.0 - 14: * @since 0.1.0 Use a default Locale and Currency. - 15: * @since 0.1.1 The object can be echoed now. - 16: * @package ep6 - 17: * @subpackage Shopobjects\Product - 18: * @example examples\createProductFilter.php Create and use the product filter. + 13: * @package ep6 + 14: * @since 0.0.0 + 15: * @since 0.1.0 Use a default Locale and Currency. + 16: * @since 0.1.1 The object can be echoed now. + 17: * @since 0.1.2 Add error reporting. + 18: * @subpackage Shopobjects\Product 19: */ 20: class ProductFilter { 21: - 22: /** @var String The REST path to the filter ressource. */ - 23: const RESTPATH = "products"; - 24: - 25: /** @var int The page of the product search result. */ - 26: private $page = 1; - 27: - 28: /** @var int The number of results per page of the product search result. */ - 29: private $resultsPerPage = 10; - 30: - 31: /** @var String|null The sort direction of the product search result. */ - 32: private $direction; - 33: - 34: /** @var String The variable to sort the results of the product search result. */ - 35: private $sort = "name"; - 36: - 37: /** @var String|null The search string of the product search result. */ - 38: private $q; - 39: - 40: /** @var String|null The category id of the product search result. */ - 41: private $categoryID; - 42: - 43: /** @var String[] The product ids of the product search result. */ - 44: private $IDs = array(); - 45: - 46: /** - 47: * This is the constructor to prefill the product filter. - 48: * - 49: * @author David Pauli <contact@david-pauli.de> - 50: * @since 0.0.1 - 51: * @api + 22: use ErrorReporting; + 23: + 24: /** @var String The REST path to the filter ressource. */ + 25: const RESTPATH = "products"; + 26: + 27: /** @var String|null The category id of the product search result. */ + 28: private $categoryID; + 29: + 30: /** @var String|null The sort direction of the product search result. */ + 31: private $direction; + 32: + 33: /** @var String[] The product ids of the product search result. */ + 34: private $IDs = array(); + 35: + 36: /** @var int The page of the product search result. */ + 37: private $page = 1; + 38: + 39: /** @var String|null The search string of the product search result. */ + 40: private $q; + 41: + 42: /** @var int The number of results per page of the product search result. */ + 43: private $resultsPerPage = 10; + 44: + 45: /** @var String The variable to sort the results of the product search result. */ + 46: private $sort = "name"; + 47: + 48: /** + 49: * This is the constructor to prefill the product filter. + 50: * + 51: * @author David Pauli <contact@david-pauli.de> 52: * @param String[] $productFilterParameter The values of a product filter. - 53: */ - 54: public function __construct($productFilterParameter = array()) { - 55: - 56: if (InputValidator::isArray($productFilterParameter) && - 57: !InputValidator::isEmptyArray($productFilterParameter)) { - 58: $this->setProductFilter($productFilterParameter); - 59: } - 60: } - 61: - 62: /** - 63: * Fill the product filter with a array. - 64: * - 65: * @author David Pauli <contact@david-pauli.de> - 66: * @since 0.0.1 - 67: * @since 0.1.0 Use a default Locale and Currency. - 68: * @api - 69: * @param String[] $productFilterParameter The values of a product filter. - 70: */ - 71: public function setProductFilter($productFilterParameter) { - 72: - 73: if (!InputValidator::isArray($productFilterParameter) || - 74: InputValidator::isEmptyArray($productFilterParameter)) { - 75: return; - 76: } - 77: - 78: foreach ($productFilterParameter as $key => $parameter) { - 79: if($key == "page") { - 80: $this->setPage($parameter); - 81: } - 82: else if($key == "resultsPerPage") { - 83: $this->setResultsPerPage($parameter); - 84: } - 85: else if($key == "direction") { - 86: $this->setDirection($parameter); - 87: } - 88: else if($key == "sort") { - 89: $this->setSort($parameter); - 90: } - 91: else if($key == "q") { - 92: $this->setQ($parameter); - 93: } - 94: else if($key == "categoryID") { - 95: $this->setCategoryID($parameter); - 96: } - 97: else { - 98: Logger::warning("Unknown attribute <i>" . $key . "</i> in product filter attribute."); - 99: } -100: } -101: } -102: -103: /** -104: * This function prints the filter in a FORCE message. -105: * -106: * @author David Pauli <contact@david-pauli.de> -107: * @since 0.0.0 -108: * @since 0.1.0 Use a default Locale and Currency. -109: * @since 0.1.1 To print the product filter echo the object itself. -110: * @deprecated To print the product filter echo the object itself. -111: */ -112: public function printFilter() { -113: -114: Logger::force($this); -115: } -116: -117: /** -118: * This function returns the hash code of the object to equals the object. -119: * -120: * @author David Pauli <contact@david-pauli.de> -121: * @since 0.0.0 -122: * @since 0.1.0 Use a default Locale and Currency. -123: * @api -124: * @return String Returns the hash code of the object. -125: */ -126: public function hashCode() { + 53: * @since 0.0.1 + 54: */ + 55: public function __construct($productFilterParameter = array()) { + 56: + 57: if (InputValidator::isArray($productFilterParameter) && + 58: !InputValidator::isEmptyArray($productFilterParameter)) { + 59: + 60: $this->setProductFilter($productFilterParameter); + 61: } + 62: } + 63: + 64: /** + 65: * Prints the Product attribute object as a string. + 66: * + 67: * This function returns the setted values of the Product attribute object. + 68: * + 69: * @author David Pauli <contact@david-pauli.de> + 70: * @return String The Product attribute as a string. + 71: * @since 0.1.1 + 72: */ + 73: public function __toString() { + 74: + 75: return "<strong>Page:</strong> " . $this->page . "<br/>" . + 76: "<strong>Results per page:</strong> " . $this->resultsPerPage . "<br/>" . + 77: "<strong>Direction:</strong> " . $this->direction . "<br/>" . + 78: "<strong>Sort:</strong> " . $this->sort . "<br/>" . + 79: "<strong>Search string:</strong> " . $this->q . "<br/>" . + 80: "<strong>Category ID:</strong> " . $this->categoryID . "<br/>" . + 81: "<strong>Product IDs:</strong> " . print_r($this->IDs) . "<br/>"; + 82: } + 83: + 84: /** + 85: * This function returns the hash code of the object to equals the object. + 86: * + 87: * @author David Pauli <contact@david-pauli.de> + 88: * @return String Returns the hash code of the object. + 89: * @since 0.0.0 + 90: * @since 0.1.0 Use a default Locale and Currency. + 91: * @since 0.1.2 Add error reporting. + 92: */ + 93: public function hashCode() { + 94: + 95: $this->errorReset(); + 96: + 97: $message = $this->page + 98: . $this->resultsPerPage + 99: . $this->direction +100: . $this->sort +101: . $this->q +102: . $this->categoryID; +103: +104: foreach ($this->IDs as $id) { +105: +106: $message .= $id; +107: } +108: +109: return hash("sha512", $message); +110: } +111: +112: /** +113: * This function gets the category ID string. +114: * +115: * @author David Pauli <contact@david-pauli.de> +116: * @return String The category ID string of this product filter. +117: * @since 0.0.0 +118: * @since 0.1.0 Use attribute unstatic. +119: * @since 0.1.2 Add error reporting. +120: */ +121: public function getCategoryID() { +122: +123: $this->errorReset(); +124: +125: return $this->categoryID; +126: } 127: -128: $message = $this->page -129: . $this->resultsPerPage -130: . $this->direction -131: . $this->sort -132: . $this->q -133: . $this->categoryID; -134: foreach ($this->IDs as $id) { -135: $message .= $id; -136: } -137: return hash("sha512", $message); -138: } -139: -140: /** -141: * This function sets the localization. -142: * -143: * @author David Pauli <contact@david-pauli.de> -144: * @since 0.0.0 -145: * @since 0.1.0 Deprecate because product filter now use shop configured Locale. -146: * @api -147: * @deprecated -148: * @param String $locale The localiazion to filter. -149: * @return boolean True if setting the locale works, false if not. -150: */ -151: public function setLocale($locale) { -152: return false; -153: } +128: /** +129: * This function gets the direction. +130: * +131: * @author David Pauli <contact@david-pauli.de> +132: * @return String The direction of this product filter. +133: * @since 0.0.0 +134: * @since 0.1.0 Use attribute unstatic. +135: * @since 0.1.2 Add error reporting. +136: */ +137: public function getDirection() { +138: +139: $this->errorReset(); +140: +141: return $this->direction; +142: } +143: +144: /** +145: * This function gets the page. +146: * +147: * @author David Pauli <contact@david-pauli.de> +148: * @return int The page number of this product filter. +149: * @since 0.0.0 +150: * @since 0.1.0 Use attribute unstatic. +151: * @since 0.1.2 Add error reporting. +152: */ +153: public function getPage() { 154: -155: /** -156: * This function gets the localization. -157: * -158: * @author David Pauli <contact@david-pauli.de> -159: * @since 0.0.0 -160: * @since 0.1.0 Deprecate because product filter now use shop configured Locale. -161: * @api -162: * @deprecated -163: * @return String The localization of this product filter. -164: */ -165: public function getLocale() { -166: return Locales::getLocale(); -167: } -168: -169: /** -170: * This function sets the currency. -171: * -172: * @author David Pauli <contact@david-pauli.de> -173: * @since 0.0.0 -174: * @since 0.1.0 Deprecate because product filter now use shop configured Currency. -175: * @api -176: * @deprecated -177: * @param String $currency The currency to filter. -178: * @return boolean True if setting the currency works, false if not. -179: */ -180: public function setCurrency($currency) { -181: return false; -182: } -183: -184: /** -185: * This function gets the currency. -186: * -187: * @author David Pauli <contact@david-pauli.de> -188: * @since 0.0.0 -189: * @since 0.1.0 Deprecate because product filter now use shop configured Currency. -190: * @api -191: * @deprecated -192: * @return String The currency of this product filter. -193: */ -194: public function getCurrency() { -195: return Currencies::getCurrency(); -196: } +155: $this->errorReset(); +156: +157: return $this->page; +158: } +159: +160: /** +161: * This function returns the products by using the product filter. +162: * +163: * @author David Pauli <contact@david-pauli.de> +164: * @since 0.0.0 +165: * @since 0.1.0 Use a default Locale. +166: * @since 0.1.1 Unstatic every attributes. +167: * @since 0.1.2 Add error reporting. +168: * @return Products[] Returns an array of products. +169: */ +170: public function getProducts() { +171: +172: $this->errorReset(); +173: +174: $parameter = $this->getParameter(); +175: +176: // if request method is blocked +177: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { +178: +179: $this->errorSet("RESTC-9"); +180: return; +181: } +182: +183: $content = RESTClient::send(self::RESTPATH . "?" . $parameter); +184: +185: // if respond is empty +186: if (InputValidator::isEmpty($content)) { +187: +188: $this->errorSet("PF-8"); +189: Logger::error("ep6\ProductFilter\nREST respomd for getting products is empty."); +190: return; +191: } +192: +193: // if there is no results, page AND resultsPerPage element +194: if (InputValidator::isEmptyArrayKey($content, "results") || +195: InputValidator::isEmptyArrayKey($content, "page") || +196: InputValidator::isEmptyArrayKey($content, "resultsPerPage")) { 197: -198: /** -199: * This function sets the page to show. -200: * -201: * @author David Pauli <contact@david-pauli.de> -202: * @since 0.0.0 -203: * @since 0.1.0 Use attribute unstatic. -204: * @api -205: * @param int $page The page number to filter. -206: * @return boolean True if setting the page works, false if not. -207: */ -208: public function setPage($page) { -209: if (!InputValidator::isRangedInt($page, 1)) { -210: return false; -211: } -212: $this->page = $page; -213: return true; -214: } -215: -216: /** -217: * This function gets the page. -218: * -219: * @author David Pauli <contact@david-pauli.de> -220: * @since 0.0.0 -221: * @since 0.1.0 Use attribute unstatic. -222: * @api -223: * @return int The page number of this product filter. -224: */ -225: public function getPage() { -226: return $this->page; -227: } +198: $this->errorSet("PF-9"); +199: Logger::error("ep6\ProductFilter\nRespond for " . self::RESTPATH . " can not be interpreted."); +200: return; +201: } +202: +203: $products = array(); +204: +205: // is there any product found: load the products. +206: if (!InputValidator::isEmptyArrayKey($content, "items") && (sizeof($content['items']) != 0)) { +207: +208: foreach ($content['items'] as $item) { +209: +210: $product = new Product($item); +211: array_push($products, $product); +212: } +213: } +214: +215: return $products; +216: } +217: +218: /** +219: * This function gets the query search string. +220: * +221: * @author David Pauli <contact@david-pauli.de> +222: * @return String The query search string of this product filter. +223: * @since 0.0.0 +224: * @since 0.1.0 Use attribute unstatic. +225: * @since 0.1.2 Add error reporting. +226: */ +227: public function getQ() { 228: -229: /** -230: * This function sets the results per page to show. -231: * -232: * @author David Pauli <contact@david-pauli.de> -233: * @since 0.0.0 -234: * @since 0.1.0 Use attribute unstatic. -235: * @api -236: * @param int $resultsPerPage The results per page to filter. -237: * @return boolean True if setting the results per page works, false if not. -238: */ -239: public function setResultsPerPage($resultsPerPage) { -240: if (!InputValidator::isRangedInt($resultsPerPage, null, 100)) { -241: return false; -242: } -243: $this->resultsPerPage = $resultsPerPage; -244: return true; -245: } +229: $this->errorReset(); +230: +231: return $this->q; +232: } +233: +234: /** +235: * This function gets the results per page. +236: * +237: * @author David Pauli <contact@david-pauli.de> +238: * @return int The results per page number of this product filter. +239: * @since 0.0.0 +240: * @since 0.1.0 Use attribute unstatic. +241: * @since 0.1.2 Add error reporting. +242: */ +243: public function getResultsPerPage() { +244: +245: $this->errorReset(); 246: -247: /** -248: * This function gets the results per page. -249: * -250: * @author David Pauli <contact@david-pauli.de> -251: * @since 0.0.0 -252: * @since 0.1.0 Use attribute unstatic. -253: * @api -254: * @return int The results per page number of this product filter. -255: */ -256: public function getResultsPerPage() { -257: return $this->resultsPerPage; -258: } -259: -260: /** -261: * This function sets the direction to show. -262: * -263: * @author David Pauli <contact@david-pauli.de> -264: * @since 0.0.0 -265: * @since 0.1.0 Use attribute unstatic. -266: * @api -267: * @param String $direction The direction to filter. -268: * @return boolean True if setting the direction works, false if not. -269: */ -270: public function setDirection($direction) { -271: if (!InputValidator::isProductDirection($direction)) { -272: return false; -273: } -274: $this->direction = $direction; -275: return true; -276: } -277: -278: /** -279: * This function gets the direction. -280: * -281: * @author David Pauli <contact@david-pauli.de> -282: * @since 0.0.0 -283: * @since 0.1.0 Use attribute unstatic. -284: * @api -285: * @return String The direction of this product filter. -286: */ -287: public function getDirection() { -288: return $this->direction; -289: } -290: -291: /** -292: * This function sets the order parameter to show. -293: * -294: * @author David Pauli <contact@david-pauli.de> -295: * @since 0.0.0 -296: * @since 0.1.0 Use attribute unstatic. -297: * @api -298: * @param String $sort The sort parameter to filter. -299: * @return boolean True if setting the sort parameter works, false if not. -300: */ -301: public function setSort($sort) { -302: if (!InputValidator::isProductSort($sort)) { -303: return false; -304: } -305: $this->sort = $sort; -306: return true; -307: } -308: -309: /** -310: * This function gets the sort. -311: * -312: * @author David Pauli <contact@david-pauli.de> -313: * @since 0.0.0 -314: * @since 0.1.0 Use attribute unstatic. -315: * @api -316: * @return String The sort of this product filter. -317: */ -318: public function getSort() { -319: return $this->sort; +247: return $this->resultsPerPage; +248: } +249: +250: /** +251: * This function gets the sort. +252: * +253: * @author David Pauli <contact@david-pauli.de> +254: * @return String The sort of this product filter. +255: * @since 0.0.0 +256: * @since 0.1.0 Use attribute unstatic. +257: * @since 0.1.2 Add error reporting. +258: */ +259: public function getSort() { +260: +261: $this->errorReset(); +262: +263: return $this->sort; +264: } +265: +266: /** +267: * This function reset all product IDs from filter. +268: * @author David Pauli <contact@david-pauli.de> +269: * @since 0.0.0 +270: * @since 0.1.0 Use a default Locale and Currency. +271: * @since 0.1.2 Add error reporting. +272: */ +273: public function resetFilter() { +274: +275: $this->errorReset(); +276: +277: $this->page = 1; +278: $this->resultsPerPage = 10; +279: $this->direction = null; +280: $this->sort = "name"; +281: $this->q = null; +282: $this->categoryID = null; +283: $this->IDs = array(); +284: } +285: +286: /** +287: * This function reset all product IDs from filter. +288: * @author David Pauli <contact@david-pauli.de> +289: * @since 0.0.0 +290: * @since 0.1.0 Use attribute unstatic. +291: * @since 0.1.2 Add error reporting. +292: */ +293: public function resetIDs() { +294: +295: $this->errorReset(); +296: $this->IDs = array(); +297: } +298: +299: /** +300: * This function sets the category ID to show. +301: * +302: * @author David Pauli <contact@david-pauli.de> +303: * @param String $categoryID The category ID to filter. +304: * @return boolean True if setting the category ID string works, false if not. +305: * @since 0.0.0 +306: * @since 0.1.0 Use attribute unstatic. +307: * @since 0.1.2 Add error reporting. +308: */ +309: public function setCategoryID($categoryID) { +310: +311: $this->errorReset(); +312: +313: if (InputValidator::isEmpty($categoryID)) { +314: +315: return false; +316: } +317: +318: $this->categoryID = $categoryID; +319: return true; 320: } 321: 322: /** -323: * This function sets the query search string to show. +323: * This function sets the direction to show. 324: * 325: * @author David Pauli <contact@david-pauli.de> -326: * @since 0.0.0 -327: * @since 0.1.0 Use attribute unstatic. -328: * @api -329: * @param String $q The query search string to filter. -330: * @return boolean True if setting the query search string works, false if not. +326: * @param String $direction The direction to filter. +327: * @return boolean True if setting the direction works, false if not. +328: * @since 0.0.0 +329: * @since 0.1.0 Use attribute unstatic. +330: * @since 0.1.2 Add error reporting. 331: */ -332: public function setQ($q) { -333: if (InputValidator::isEmpty($q)) { -334: return false; -335: } -336: $this->q = $q; -337: return true; -338: } -339: -340: /** -341: * This function gets the query search string. -342: * -343: * @author David Pauli <contact@david-pauli.de> -344: * @since 0.0.0 -345: * @since 0.1.0 Use attribute unstatic. -346: * @api -347: * @return String The query search string of this product filter. -348: */ -349: public function getQ() { -350: return $this->q; -351: } -352: -353: /** -354: * This function sets the category ID to show. -355: * -356: * @author David Pauli <contact@david-pauli.de> -357: * @since 0.0.0 -358: * @since 0.1.0 Use attribute unstatic. -359: * @api -360: * @param String $categoryID The category ID to filter. -361: * @return boolean True if setting the category ID string works, false if not. -362: */ -363: public function setCategoryID($categoryID) { -364: if (InputValidator::isEmpty($categoryID)) { -365: return false; -366: } -367: $this->categoryID = $categoryID; -368: return true; -369: } +332: public function setDirection($direction) { +333: +334: $this->errorReset(); +335: +336: if (!InputValidator::isProductDirection($direction)) { +337: +338: $this->errorSet("PF-5"); +339: Logger::warning("The direction " . $direction . " as a product filter direction has not a valid value."); +340: return false; +341: } +342: +343: $this->direction = $direction; +344: return true; +345: } +346: +347: /** +348: * This function add a product ID from filter. +349: * +350: * @author David Pauli <contact@david-pauli.de> +351: * @param String $productID The product ID to filter. +352: * @return boolean True if setting the product ID string works, false if not. +353: * @since 0.0.0 +354: * @since 0.1.0 Use attribute unstatic. +355: * @since 0.1.2 Add error reporting. +356: */ +357: public function setID($productID) { +358: +359: $this->errorReset(); +360: +361: if (InputValidator::isEmpty($productID) +362: || count($this->IDs) > 12 +363: || in_array($productID, $this->IDs)) { +364: +365: if (count($this->IDs) > 12) { +366: +367: $this->errorSet("PF-7"); +368: Logger::warning("ep6\ProductFilter\nThere are already 12 product IDs to filter. To add more delete one."); +369: } 370: -371: /** -372: * This function gets the category ID string. -373: * -374: * @author David Pauli <contact@david-pauli.de> -375: * @since 0.0.0 -376: * @since 0.1.0 Use attribute unstatic. -377: * @api -378: * @return String The category ID string of this product filter. -379: */ -380: public function getCategoryID() { -381: return $this->categoryID; -382: } -383: -384: /** -385: * This function add a product ID from filter. -386: * -387: * @author David Pauli <contact@david-pauli.de> -388: * @since 0.0.0 -389: * @since 0.1.0 Use attribute unstatic. -390: * @api -391: * @param String $productID The product ID to filter. -392: * @return boolean True if setting the product ID string works, false if not. -393: */ -394: public function setID($productID) { -395: if (InputValidator::isEmpty($productID) -396: || count($this->IDs) > 12 -397: || in_array($productID, $this->IDs)) { -398: return false; -399: } -400: array_push($this->IDs, $productID); -401: return true; -402: } -403: -404: /** -405: * This function delete a product ID from filter. -406: * -407: * @author David Pauli <contact@david-pauli.de> -408: * @since 0.0.0 -409: * @since 0.1.0 Use attribute unstatic. -410: * @api -411: * @param String $productID The product ID to unset from filter. -412: * @return boolean True if unsetting the product ID string works, false if not. -413: */ -414: public function unsetID($productID) { -415: if (InputValidator::isEmpty($productID) -416: || !in_array($productID, $this->IDs)) { -417: return false; -418: } -419: unset($this->IDs[array_search($productID, $this->IDs)]); -420: return true; -421: } -422: -423: /** -424: * This function reset all product IDs from filter. -425: * @author David Pauli <contact@david-pauli.de> -426: * @since 0.0.0 -427: * @since 0.1.0 Use attribute unstatic. -428: * @api -429: */ -430: public function resetIDs() { -431: $this->IDs = array(); -432: } -433: -434: /** -435: * This function reset all product IDs from filter. -436: * @author David Pauli <contact@david-pauli.de> -437: * @since 0.0.0 -438: * @since 0.1.0 Use a default Locale and Currency. -439: * @api -440: */ -441: public function resetFilter() { -442: -443: $this->page = 1; -444: $this->resultsPerPage = 10; -445: $this->direction = null; -446: $this->sort = "name"; -447: $this->q = null; -448: $this->categoryID = null; -449: $this->IDs = array(); -450: } +371: return false; +372: } +373: +374: array_push($this->IDs, $productID); +375: return true; +376: } +377: +378: /** +379: * This function sets the page to show. +380: * +381: * @author David Pauli <contact@david-pauli.de> +382: * @param int $page The page number to filter. +383: * @return boolean True if setting the page works, false if not. +384: * @since 0.0.0 +385: * @since 0.1.0 Use attribute unstatic. +386: * @since 0.1.2 Add error reporting. +387: */ +388: public function setPage($page) { +389: +390: $this->errorReset(); +391: +392: if (!InputValidator::isRangedInt($page, 1)) { +393: +394: $this->errorSet("PF-3"); +395: Logger::warning("ep6\ProductFilter\nThe number " . $page . " as a product filter page needs to be bigger than 0."); +396: return false; +397: } +398: +399: $this->page = $page; +400: return true; +401: } +402: +403: /** +404: * Fill the product filter with a array. +405: * +406: * @author David Pauli <contact@david-pauli.de> +407: * @return String The Product attribute as a string. +408: * @since 0.0.1 +409: * @since 0.1.0 Use a default Locale and Currency. +410: * @since 0.1.2 Add error reporting. +411: */ +412: public function setProductFilter($productFilterParameter) { +413: +414: $this->errorReset(); +415: +416: if (!InputValidator::isArray($productFilterParameter) || +417: InputValidator::isEmptyArray($productFilterParameter)) { +418: +419: $this->errorSet("PF-1"); +420: Logger::warning("ep6\ProductFilter\nProduct filter parameter " . $productFilterParameter . " to create product filter is invalid."); +421: return; +422: } +423: +424: foreach ($productFilterParameter as $key => $parameter) { +425: +426: if($key == "page") { +427: +428: $this->setPage($parameter); +429: } +430: else if($key == "resultsPerPage") { +431: +432: $this->setResultsPerPage($parameter); +433: } +434: else if($key == "direction") { +435: +436: $this->setDirection($parameter); +437: } +438: else if($key == "sort") { +439: +440: $this->setSort($parameter); +441: } +442: else if($key == "q") { +443: +444: $this->setQ($parameter); +445: } +446: else if($key == "categoryID") { +447: +448: $this->setCategoryID($parameter); +449: } +450: else { 451: -452: /** -453: * This function returns the products by using the product filter. -454: * -455: * @author David Pauli <contact@david-pauli.de> -456: * @since 0.0.0 -457: * @since 0.1.0 Use a default Locale. -458: * @since 0.1.1 Unstatic every attributes. -459: * @api -460: * @return Products[] Returns an array of products. -461: */ -462: public function getProducts() { -463: -464: $parameter = $this->getParameter(); -465: -466: // if request method is blocked -467: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { -468: return; -469: } -470: -471: $content = RESTClient::send(self::RESTPATH . "?" . $parameter); -472: -473: // if respond is empty -474: if (InputValidator::isEmpty($content)) { -475: return; -476: } -477: -478: // if there is no results, page AND resultsPerPage element -479: if (InputValidator::isEmptyArrayKey($content, "results") || -480: InputValidator::isEmptyArrayKey($content, "page") || -481: InputValidator::isEmptyArrayKey($content, "resultsPerPage")) { -482: Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); -483: return; -484: } -485: -486: $products = array(); -487: // is there any product found: load the products. -488: if (!InputValidator::isEmptyArrayKey($content, "items") && (sizeof($content['items']) != 0)) { -489: -490: foreach ($content['items'] as $item) { -491: -492: $product = new Product($item); -493: array_push($products, $product); -494: } -495: } -496: -497: return $products; -498: } -499: -500: /** -501: * This function returns the parameter as string. -502: * -503: * @author David Pauli <contact@david-pauli.de> -504: * @since 0.0.0 -505: * @since 0.1.0 Use a default Locale and Currency. -506: * @api -507: * @return String The parameter build with this product filter. -508: */ -509: private function getParameter() { -510: -511: $parameter = array(); -512: array_push($parameter, "locale=" . Locales::getLocale()); -513: array_push($parameter, "currency=" . Currencies::getCurrency()); -514: if (!InputValidator::isEmpty($this->page)) array_push($parameter, "page=" . $this->page); -515: if (!InputValidator::isEmpty($this->resultsPerPage)) array_push($parameter, "resultsPerPage=" . $this->resultsPerPage); -516: if (!InputValidator::isEmpty($this->direction)) array_push($parameter, "direction=" . $this->direction); -517: if (!InputValidator::isEmpty($this->sort)) array_push($parameter, "sort=" . $this->sort); -518: if (!InputValidator::isEmpty($this->q)) array_push($parameter, "q=" . $this->q); -519: if (!InputValidator::isEmpty($this->categoryID)) array_push($parameter, "categoryId=" . $this->categoryID); -520: foreach ($this->IDs as $number => $id) { -521: array_push($parameter, "id=" . $id); -522: } +452: $this->errorSet("PF-2"); +453: Logger::warning("ep6\ProductFilter\nUnknown attribute <i>" . $key . "</i> in product filter attribute."); +454: } +455: } +456: } +457: +458: /** +459: * This function sets the query search string to show. +460: * +461: * @author David Pauli <contact@david-pauli.de> +462: * @param String $q The query search string to filter. +463: * @return boolean True if setting the query search string works, false if not. +464: * @since 0.0.0 +465: * @since 0.1.0 Use attribute unstatic. +466: * @since 0.1.2 Add error reporting. +467: */ +468: public function setQ($q) { +469: +470: $this->errorReset(); +471: +472: if (InputValidator::isEmpty($q)) { +473: +474: return false; +475: } +476: +477: $this->q = $q; +478: +479: return true; +480: } +481: +482: /** +483: * This function sets the results per page to show. +484: * +485: * @author David Pauli <contact@david-pauli.de> +486: * @param int $resultsPerPage The results per page to filter. +487: * @return boolean True if setting the results per page works, false if not. +488: * @since 0.0.0 +489: * @since 0.1.0 Use attribute unstatic. +490: * @since 0.1.2 Add error reporting. +491: */ +492: public function setResultsPerPage($resultsPerPage) { +493: +494: $this->errorReset(); +495: +496: if (!InputValidator::isRangedInt($resultsPerPage, null, 100)) { +497: +498: $this->errorSet("PF-4"); +499: Logger::warning("ep6\ProductFilter\The number " . $resultsPerPage . " as a product filter results per page needs to be lower than 100."); +500: return false; +501: } +502: +503: $this->resultsPerPage = $resultsPerPage; +504: +505: return true; +506: } +507: +508: /** +509: * This function sets the order parameter to show. +510: * +511: * @author David Pauli <contact@david-pauli.de> +512: * @param String $sort The sort parameter to filter. +513: * @return boolean True if setting the sort parameter works, false if not. +514: * @since 0.0.0 +515: * @since 0.1.0 Use attribute unstatic. +516: * @since 0.1.2 Add error reporting. +517: */ +518: public function setSort($sort) { +519: +520: $this->errorReset(); +521: +522: if (!InputValidator::isProductSort($sort)) { 523: -524: return implode("&", $parameter); -525: } -526: -527: /** -528: * Prints the Product attribute object as a string. -529: * -530: * This function returns the setted values of the Product attribute object. -531: * -532: * @author David Pauli <contact@david-pauli.de> -533: * @since 0.1.1 -534: * @return String The Product attribute as a string. -535: */ -536: public function __toString() { -537: -538: return "<strong>Page:</strong> " . $this->page . "<br/>" . -539: "<strong>Results per page:</strong> " . $this->resultsPerPage . "<br/>" . -540: "<strong>Direction:</strong> " . $this->direction . "<br/>" . -541: "<strong>Sort:</strong> " . $this->sort . "<br/>" . -542: "<strong>Search string:</strong> " . $this->q . "<br/>" . -543: "<strong>Category ID:</strong> " . $this->categoryID . "<br/>" . -544: "<strong>Product IDs:</strong> " . print_r($this->IDs) . "<br/>"; -545: } -546: } -547: ?> +524: $this->errorSet("PF-6"); +525: Logger::warning("ep6\ProductFilter\nThe parameter " . $sort . " as a product filter sort has not a valid value."); +526: return false; +527: } +528: +529: $this->sort = $sort; +530: +531: return true; +532: } +533: +534: /** +535: * This function delete a product ID from filter. +536: * +537: * @author David Pauli <contact@david-pauli.de> +538: * @param String $productID The product ID to unset from filter. +539: * @return boolean True if unsetting the product ID string works, false if not. +540: * @since 0.0.0 +541: * @since 0.1.0 Use attribute unstatic. +542: * @since 0.1.2 Add error reporting. +543: */ +544: public function unsetID($productID) { +545: +546: $this->errorReset(); +547: +548: if (InputValidator::isEmpty($productID) +549: || !in_array($productID, $this->IDs)) { +550: +551: return false; +552: } +553: +554: unset($this->IDs[array_search($productID, $this->IDs)]); +555: +556: return true; +557: } +558: +559: /** +560: * This function returns the parameter as string. +561: * +562: * @author David Pauli <contact@david-pauli.de> +563: * @return String The parameter build with this product filter. +564: * @since 0.0.0 +565: * @since 0.1.0 Use a default Locale and Currency. +566: */ +567: private function getParameter() { +568: +569: $parameter = array(); +570: array_push($parameter, "locale=" . Locales::getLocale()); +571: array_push($parameter, "currency=" . Currencies::getCurrency()); +572: +573: if (!InputValidator::isEmpty($this->page)) array_push($parameter, "page=" . $this->page); +574: if (!InputValidator::isEmpty($this->resultsPerPage)) array_push($parameter, "resultsPerPage=" . $this->resultsPerPage); +575: if (!InputValidator::isEmpty($this->direction)) array_push($parameter, "direction=" . $this->direction); +576: if (!InputValidator::isEmpty($this->sort)) array_push($parameter, "sort=" . $this->sort); +577: if (!InputValidator::isEmpty($this->q)) array_push($parameter, "q=" . $this->q); +578: if (!InputValidator::isEmpty($this->categoryID)) array_push($parameter, "categoryId=" . $this->categoryID); +579: +580: foreach ($this->IDs as $number => $id) { +581: +582: array_push($parameter, "id=" . $id); +583: } +584: +585: return implode("&", $parameter); +586: } +587: } +588: ?> - + diff --git a/doc/source-class-ep6.ProductPrice.html b/doc/source-class-ep6.ProductPrice.html new file mode 100644 index 0000000..9bb8540 --- /dev/null +++ b/doc/source-class-ep6.ProductPrice.html @@ -0,0 +1,252 @@ + + + + + + + File shopobjects/price/ProductPrice.class.php + + + + + + +
    + +
    + +
    + + + + + + diff --git a/doc/source-class-ep6.ProductPriceType.html b/doc/source-class-ep6.ProductPriceType.html new file mode 100644 index 0000000..227eb26 --- /dev/null +++ b/doc/source-class-ep6.ProductPriceType.html @@ -0,0 +1,138 @@ + + + + + + + File shopobjects/price/ProductPriceType.enum.php + + + + + + +
    + +
    + +
    + + + + + + diff --git a/doc/source-class-ep6.ProductPriceWithQuantity.html b/doc/source-class-ep6.ProductPriceWithQuantity.html new file mode 100644 index 0000000..48614df --- /dev/null +++ b/doc/source-class-ep6.ProductPriceWithQuantity.html @@ -0,0 +1,251 @@ + + + + + + + File shopobjects/price/ProductPriceWithQuantity.class.php + + + + + + +
    + +
    + +
    + + + + + + diff --git a/doc/source-class-ep6.ProductSlideshow.html b/doc/source-class-ep6.ProductSlideshow.html index c885d96..0a6f822 100644 --- a/doc/source-class-ep6.ProductSlideshow.html +++ b/doc/source-class-ep6.ProductSlideshow.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,7 +101,7 @@

    Traits

      1: <?php
       2: /**
    -  3:  * This file represents the product slideshow class.
    +  3:  * This file represents the Product Slideshow class.
       4:  *
       5:  * @author David Pauli <contact@david-pauli.de>
       6:  * @since 0.1.0
    @@ -107,275 +111,320 @@ 

    Traits

    10: * This is the product slideshow class which saves all images of the slideshow. 11: * 12: * @author David Pauli <contact@david-pauli.de> - 13: * @since 0.1.0 - 14: * @since 0.1.1 Can print the object itself. - 15: * @since 0.1.1 Delete functionality to reload itself. - 16: * @since 0.1.1 Use unstatic objects. - 17: * @api - 18: * @package ep6 + 13: * @package ep6 + 14: * @since 0.1.0 + 15: * @since 0.1.1 Can print the object itself. + 16: * @since 0.1.1 Delete functionality to reload itself. + 17: * @since 0.1.1 Use unstatic objects. + 18: * @since 0.1.2 Add error reporting. 19: * @subpackage Shopobjects\Product 20: */ 21: class ProductSlideshow { 22: - 23: /** @var String The REST path to the product slideshow ressource. */ - 24: const RESTPATH = "slideshow"; - 25: - 26: /** @var Image[] The space for the images. - 27: * - 28: * It is saved like: - 29: * [0] - 30: * [Thumbnail] - 31: * [Small] - 32: * [...] - 33: * [1] + 23: use ErrorReporting; + 24: + 25: /** @var String The REST path to the product slideshow ressource. */ + 26: const RESTPATH = "slideshow"; + 27: + 28: /** @var Image[] The space for the images. + 29: * + 30: * It is saved like: + 31: * [0] + 32: * [Thumbnail] + 33: * [Small] 34: * [...] - 35: */ - 36: private $images = array(); - 37: - 38: /** - 39: * Constructor of the Slideshow. - 40: * - 41: * @author David Pauli <contact@david-pauli.de> - 42: * @since 0.1.0 - 43: * @api + 35: * [1] + 36: * [...] + 37: */ + 38: private $images = array(); + 39: + 40: /** + 41: * Constructor of the Slideshow. + 42: * + 43: * @author David Pauli <contact@david-pauli.de> 44: * @param String $productID The product ID to get images. - 45: */ - 46: public function __construct($productID) { - 47: $this->load($productID); - 48: } - 49: - 50: /** - 51: * This function gets the product images. - 52: * - 53: * @author David Pauli <contact@david-pauli.de> - 54: * @since 0.1.0 - 55: * @since 0.1.1 Fix bug with nonsetted product URL and delete reload functionality. - 56: * @since 0.1.1 Use unstatic variables. - 57: * @api - 58: * @param String $productID The product ID to get images. - 59: */ - 60: private function load($productID) { - 61: - 62: // if parameter is wrong or GET is blocked - 63: if (!InputValidator::isProductId($productID) || - 64: !RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { - 65: return; - 66: } - 67: - 68: $content = RESTClient::send("products/" . $productID . "/" . self::RESTPATH); - 69: - 70: // if respond is empty - 71: if (InputValidator::isEmpty($content)) { - 72: return; - 73: } - 74: - 75: // if there is items - 76: if (InputValidator::isEmptyArrayKey($content, "items")) { - 77: Logger::error("Respond for product/" . $productID . "/" . self::RESTPATH . " can not be interpreted."); - 78: return; - 79: } - 80: - 81: // is there any images found: load the images. - 82: foreach ($content['items'] as $number => $image) { - 83: - 84: // parse every image size - 85: if (!InputValidator::isEmptyArrayKey($image, "sizes")) { - 86: - 87: $object = null; - 88: foreach ($image["sizes"] as $size) { - 89: - 90: // if there is "url" and "classifier" set in the image - 91: if (!InputValidator::isEmptyArrayKey($size, "url") && - 92: !InputValidator::isEmptyArrayKey($size, "classifier")) { - 93: $object[$size["classifier"]] = $size["url"]; - 94: } - 95: } - 96: - 97: // if all needed sizes are available, save it - 98: if (!InputValidator::isEmptyArrayKey($object, "Thumbnail") && - 99: !InputValidator::isEmptyArrayKey($object, "Small") && -100: !InputValidator::isEmptyArrayKey($object, "HotDeal") && -101: !InputValidator::isEmptyArrayKey($object, "MediumSmall") && -102: !InputValidator::isEmptyArrayKey($object, "Medium") && -103: !InputValidator::isEmptyArrayKey($object, "MediumLarge") && -104: !InputValidator::isEmptyArrayKey($object, "Large")) { -105: array_push($this->images, $object); -106: } -107: } -108: } -109: } -110: -111: /** -112: * Gets the number of available images. -113: * -114: * @author David Pauli <contact@david-pauli.de> -115: * @since 0.1.0 -116: * @api -117: * @return int The number of images. -118: */ -119: public function getCountImages() { -120: -121: if (InputValidator::isEmpty($this->images)) { -122: return 0; -123: } -124: return sizeof($this->images); -125: } -126: -127: /** -128: * Returns a thumbnail image. -129: * -130: * @author David Pauli <contact@david-pauli.de> -131: * @since 0.1.0 -132: * @since 0.1.1 Fix bug with returning image. -133: * @api -134: * @param int $image The image number to get -135: * @return Image|null The thumbnail image. -136: */ -137: public function getThumbnailImage($image) { -138: -139: if ($this->getCountImages() == 0 || -140: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -141: InputValidator::isEmptyArrayKey($this->images[$image], "Thumbnail")) { -142: return null; -143: } -144: return $this->images[$image]["Thumbnail"]; -145: } -146: -147: /** -148: * Returns a small image. -149: * -150: * @author David Pauli <contact@david-pauli.de> -151: * @since 0.1.0 -152: * @since 0.1.1 Fix bug with returning image. -153: * @api -154: * @param int $image The image number to get -155: * @return Image|null The small image. -156: */ -157: public function getSmallImage($image) { -158: -159: if ($this->getCountImages() == 0 || -160: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -161: InputValidator::isEmptyArrayKey($this->images[$image], "Small")) { -162: return null; -163: } -164: return $this->images[$image]["Small"]; -165: } -166: -167: /** -168: * Returns a hotdeal image. -169: * -170: * @author David Pauli <contact@david-pauli.de> -171: * @since 0.1.0 -172: * @since 0.1.1 Fix bug with returning image. -173: * @api -174: * @param int $image The image number to get -175: * @return Image|null The hotdeal image. -176: */ -177: public function getHotDealImage($image) { -178: -179: if ($this->getCountImages() == 0 || -180: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -181: InputValidator::isEmptyArrayKey($this->images[$image], "HotDeal")) { -182: return null; -183: } -184: return $this->images[$image]["HotDeal"]; -185: } -186: -187: /** -188: * Returns a medium small image. -189: * -190: * @author David Pauli <contact@david-pauli.de> -191: * @since 0.1.0 -192: * @since 0.1.1 Fix bug with returning image. -193: * @api -194: * @param int $image The image number to get -195: * @return Image|null The medium small image. -196: */ -197: public function getMediumSmallImage($image) { -198: -199: if ($this->getCountImages() == 0 || -200: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -201: InputValidator::isEmptyArrayKey($this->images[$image], "MediumSmall")) { -202: return null; -203: } -204: return $this->images[$image]["MediumSmall"]; -205: } -206: -207: /** -208: * Returns a medium image. -209: * -210: * @author David Pauli <contact@david-pauli.de> -211: * @since 0.1.0 -212: * @since 0.1.1 Fix bug with returning image. -213: * @api -214: * @param int $image The image number to get -215: * @return Image|null The medium image. -216: */ -217: public function getMediumImage($image) { -218: -219: if ($this->getCountImages() == 0 || -220: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -221: InputValidator::isEmptyArrayKey($this->images[$image], "Medium")) { -222: return null; -223: } -224: return $this->images[$image]["Medium"]; -225: } -226: -227: /** -228: * Returns a medium large image. -229: * -230: * @author David Pauli <contact@david-pauli.de> -231: * @since 0.1.0 -232: * @since 0.1.1 Fix bug with returning image. -233: * @api -234: * @param int $image The image number to get -235: * @return Image|null The medium large image. -236: */ -237: public function getMediumLargeImage($image) { -238: -239: if ($this->getCountImages() == 0 || -240: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -241: InputValidator::isEmptyArrayKey($this->images[$image], "MediumLarge")) { + 45: * @since 0.1.0 + 46: */ + 47: public function __construct($productID) { + 48: + 49: $this->load($productID); + 50: } + 51: + 52: /** + 53: * Prints the Product slideshow object as a string. + 54: * + 55: * This function returns the setted values of the Product slideshow object. + 56: * + 57: * @author David Pauli <contact@david-pauli.de> + 58: * @return String The Product slideshow as a string. + 59: * @since 0.1.1 + 60: */ + 61: public function __toString() { + 62: + 63: return "<strong>Images:</strong> " . print_r($this->images) . "<br/>"; + 64: } + 65: + 66: /** + 67: * Gets the number of available images. + 68: * + 69: * @author David Pauli <contact@david-pauli.de> + 70: * @return int The number of images. + 71: * @since 0.1.0 + 72: * @since 0.1.2 Add error reporting. + 73: */ + 74: public function getCountImages() { + 75: + 76: $this->errorReset(); + 77: + 78: if (InputValidator::isEmpty($this->images)) { + 79: + 80: return 0; + 81: } + 82: + 83: return sizeof($this->images); + 84: } + 85: + 86: /** + 87: * Returns a hotdeal image. + 88: * + 89: * @author David Pauli <contact@david-pauli.de> + 90: * @param int $image The image number to get + 91: * @return Image|null The hotdeal image. + 92: * @since 0.1.0 + 93: * @since 0.1.1 Fix bug with returning image. + 94: * @since 0.1.2 Add error reporting and easy the function. + 95: */ + 96: public function getHotDealImage($image) { + 97: + 98: $this->errorReset(); + 99: +100: return $this->getImage($image, "HotDeal"); +101: } +102: +103: /** +104: * Returns a large image. +105: * +106: * @author David Pauli <contact@david-pauli.de> +107: * @param int $image The image number to get +108: * @return Image|null The large image. +109: * @since 0.1.0 +110: * @since 0.1.1 Fix bug with returning image. +111: * @since 0.1.2 Add error reporting and easy the function. +112: */ +113: public function getLargeImage($image) { +114: +115: $this->errorReset(); +116: +117: return $this->getImage($image, "Large"); +118: } +119: +120: /** +121: * Returns a medium large image. +122: * +123: * @author David Pauli <contact@david-pauli.de> +124: * @param int $image The image number to get +125: * @return Image|null The medium large image. +126: * @since 0.1.0 +127: * @since 0.1.1 Fix bug with returning image. +128: * @since 0.1.2 Add error reporting and easy the function. +129: */ +130: public function getMediumLargeImage($image) { +131: +132: $this->errorReset(); +133: +134: return $this->getImage($image, "MediumLarge"); +135: } +136: +137: /** +138: * Returns a medium image. +139: * +140: * @author David Pauli <contact@david-pauli.de> +141: * @param int $image The image number to get +142: * @return Image|null The medium image. +143: * @since 0.1.0 +144: * @since 0.1.1 Fix bug with returning image. +145: * @since 0.1.2 Add error reporting and easy the function. +146: */ +147: public function getMediumImage($image) { +148: +149: $this->errorReset(); +150: +151: return $this->getImage($image, "Medium"); +152: } +153: +154: /** +155: * Returns a medium small image. +156: * +157: * @author David Pauli <contact@david-pauli.de> +158: * @param int $image The image number to get +159: * @return Image|null The medium small image. +160: * @since 0.1.0 +161: * @since 0.1.1 Fix bug with returning image. +162: * @since 0.1.2 Add error reporting and easy the function. +163: */ +164: public function getMediumSmallImage($image) { +165: +166: $this->errorReset(); +167: +168: return $this->getImage($image, "MediumSmall"); +169: } +170: +171: /** +172: * Returns a small image. +173: * +174: * @author David Pauli <contact@david-pauli.de> +175: * @param int $image The image number to get +176: * @return Image|null The small image. +177: * @since 0.1.0 +178: * @since 0.1.1 Fix bug with returning image. +179: * @since 0.1.2 Add error reporting and easy the function. +180: */ +181: public function getSmallImage($image) { +182: +183: $this->errorReset(); +184: +185: return $this->getImage($image, "Small"); +186: } +187: +188: /** +189: * Returns a small image. +190: * +191: * @author David Pauli <contact@david-pauli.de> +192: * @param int $image The image number to get +193: * @return Image|null The small image. +194: * @since 0.1.0 +195: * @since 0.1.1 Fix bug with returning image. +196: * @since 0.1.2 Add error reporting and easy the function. +197: */ +198: public function getThumbnailImage($image) { +199: +200: $this->errorReset(); +201: +202: return $this->getImage($image, "Thumbnail"); +203: } +204: +205: /** +206: * Basic function to return an image. +207: * +208: * @author David Pauli <contact@david-pauli.de> +209: * @param int $image The image number to get +210: * @param String $type The type of the image. +211: * @return Image|null The thumbnail image. +212: * @since 0.1.2 +213: */ +214: private function getImage($image, $type) { +215: +216: if ($this->getCountImages() == 0 || +217: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || +218: InputValidator::isEmptyArrayKey($this->images[$image], $type)) { +219: +220: $reason = $this->getCountImages() == 0 ? "noImages" : +221: (!InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1)) ? "IDunknown" : +222: "imageCorrupt"; +223: +224: switch ($reason) { +225: +226: case "noImages": +227: $this->errorSet("PS-4"); +228: Logger::warning("ep6\ProductSlideshow\nThere are no slideshow images."); +229: break; +230: +231: case "IDunknown": +232: $this->errorSet("PS-5"); +233: Logger::warning("ep6\ProductSlideshow\nThe slideshow image number is unknown."); +234: break; +235: +236: case "imageCorrupt": +237: $this->errorSet("PS-6"); +238: Logger::warning("ep6\ProductSlideshow\nThe required slideshow image exists but is empty."); +239: break; +240: } +241: 242: return null; 243: } -244: return $this->images[$image]["MediumLarge"]; -245: } -246: -247: /** -248: * Returns a large image. -249: * -250: * @author David Pauli <contact@david-pauli.de> -251: * @since 0.1.0 -252: * @since 0.1.1 Fix bug with returning image. -253: * @api -254: * @param int $image The image number to get -255: * @return Image|null The large image. -256: */ -257: public function getLargeImage($image) { -258: -259: if ($this->getCountImages() == 0 || -260: !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || -261: InputValidator::isEmptyArrayKey($this->images[$image], "Large")) { -262: return null; -263: } -264: return $this->images[$image]["Large"]; -265: } -266: -267: /** -268: * Prints the Product slideshow object as a string. -269: * -270: * This function returns the setted values of the Product slideshow object. -271: * -272: * @author David Pauli <contact@david-pauli.de> -273: * @since 0.1.1 -274: * @return String The Product slideshow as a string. -275: */ -276: public function __toString() { +244: +245: return $this->images[$image][$type]; +246: } +247: +248: +249: /** +250: * This function gets the product images. +251: * +252: * @author David Pauli <contact@david-pauli.de> +253: * @param String $productID The product ID to get images. +254: * @since 0.1.0 +255: * @since 0.1.1 Fix bug with nonsetted product URL and delete reload functionality. +256: * @since 0.1.1 Use unstatic variables. +257: * @since 0.1.2 Add error reporting. +258: */ +259: private function load($productID) { +260: +261: // if parameter is wrong +262: if (!InputValidator::isProductId($productID)) { +263: +264: $this->errorSet("PS-1"); +265: Logger::warning("ep6\ProductSlideshow\nInvalid product ID " . $productId . " to load slideshow."); +266: return; +267: } +268: +269: // if GET is blocked +270: if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { +271: +272: $this->errorSet("RESTC-9"); +273: return; +274: } +275: +276: $content = RESTClient::send("products/" . $productID . "/" . self::RESTPATH); 277: -278: return "<strong>Images:</strong> " . print_r($this->images) . "<br/>"; -279: } -280: } -281: ?>
    +278: // if respond is empty +279: if (InputValidator::isEmpty($content)) { +280: +281: $this->errorSet("PS-2"); +282: Logger::warning("ep6\ProductSlideshow\nEmpty response while getting product slideshow."); +283: return; +284: } +285: +286: // if there is items +287: if (InputValidator::isEmptyArrayKey($content, "items")) { +288: +289: $this->errorSet("PS-3"); +290: Logger::error("Respond for product slidehows can not be interpreted."); +291: return; +292: } +293: +294: // is there any images found: load the images. +295: foreach ($content['items'] as $number => $image) { +296: +297: // parse every image size +298: if (!InputValidator::isEmptyArrayKey($image, "sizes")) { +299: +300: $object = null; +301: foreach ($image["sizes"] as $size) { +302: +303: // if there is "url" and "classifier" set in the image +304: if (!InputValidator::isEmptyArrayKey($size, "url") && +305: !InputValidator::isEmptyArrayKey($size, "classifier")) { +306: +307: $object[$size["classifier"]] = $size["url"]; +308: } +309: } +310: +311: // if all needed sizes are available, save it +312: if (!InputValidator::isEmptyArrayKey($object, "Thumbnail") && +313: !InputValidator::isEmptyArrayKey($object, "Small") && +314: !InputValidator::isEmptyArrayKey($object, "HotDeal") && +315: !InputValidator::isEmptyArrayKey($object, "MediumSmall") && +316: !InputValidator::isEmptyArrayKey($object, "Medium") && +317: !InputValidator::isEmptyArrayKey($object, "MediumLarge") && +318: !InputValidator::isEmptyArrayKey($object, "Large")) { +319: +320: array_push($this->images, $object); +321: } +322: } +323: } +324: } +325: } +326: ?> - + diff --git a/doc/source-class-ep6.RESTClient.html b/doc/source-class-ep6.RESTClient.html index e5117d3..4bcc1c2 100644 --- a/doc/source-class-ep6.RESTClient.html +++ b/doc/source-class-ep6.RESTClient.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -108,298 +112,325 @@

    Traits

    11: * This is the pure REST client. It is used in a static way. 12: * 13: * @author David Pauli <contact@david-pauli.de> - 14: * @since 0.0.0 - 15: * @since 0.0.3 Use HTTPRequestMethod enum. - 16: * @since 0.1.0 Add a recommended wait time for the next request. - 17: * @since 0.1.1 Now the object is printable via echo. - 18: * @since 0.1.1 Add function to change the wait time for next REST request. - 19: * @since 0.1.1 Set $HOST and $SHOP to default value null. - 20: * @package ep6 - 21: * @subpackage Util - 22: */ - 23: class RESTClient { - 24: - 25: /** @var String|null The ePages host to connect. */ - 26: private static $HOST = null; + 14: * @package ep6 + 15: * @since 0.0.0 + 16: * @since 0.0.3 Use HTTPRequestMethod enum. + 17: * @since 0.1.0 Add a recommended wait time for the next request. + 18: * @since 0.1.1 Now the object is printable via echo. + 19: * @since 0.1.1 Add function to change the wait time for next REST request. + 20: * @since 0.1.1 Set $HOST and $SHOP to default value null. + 21: * @since 0.1.2 Add error reporting. + 22: * @subpackage Util + 23: */ + 24: class RESTClient { + 25: + 26: use ErrorReporting; 27: - 28: /** @var String|null The refered ePages ahop. */ - 29: private static $SHOP = null; + 28: /** @var String The accepted value of the response. */ + 29: const HTTP_ACCEPT = "application/vnd.epages.v1+json"; 30: - 31: /** @var String|null The authentification token (access token). */ - 32: private static $AUTHTOKEN = null; + 31: /** @var String The content type of the request. */ + 32: const HTTP_CONTENT_TYPE = "application/json"; 33: - 34: /** @var boolean|null You use https or http? Default is true. */ - 35: private static $ISSSL = true; + 34: /** @var String The path to the REST ressource in the shop. */ + 35: const PATHTOREST = "rs/shops"; 36: - 37: /** @var boolean Boolean to log whether the client is connected or not. */ - 38: private static $ISCONNECTED = false; + 37: /** @var int The time in ms the shop object should wait until the next request. */ + 38: public static $NEXT_RESPONSE_WAIT_TIME = 600; 39: - 40: /** @var HTTPRequestMethod The request method of the REST call. */ - 41: private static $HTTP_REQUEST_METHOD = HTTPRequestMethod::GET; + 40: /** @var String|null The authentification token (access token). */ + 41: private static $AUTHTOKEN = null; 42: - 43: /** @var String The path to the REST ressource in the shop. */ - 44: const PATHTOREST = "rs/shops"; + 43: /** @var String|null The ePages host to connect. */ + 44: private static $HOST = null; 45: - 46: /** @var String The accepted value of the response. */ - 47: const HTTP_ACCEPT = "application/vnd.epages.v1+json"; + 46: /** @var HTTPRequestMethod The request method of the REST call. */ + 47: private static $HTTP_REQUEST_METHOD = HTTPRequestMethod::GET; 48: - 49: /** @var String The content type of the request. */ - 50: const HTTP_CONTENT_TYPE = "application/json"; + 49: /** @var boolean Boolean to log whether the client is connected or not. */ + 50: private static $ISCONNECTED = false; 51: - 52: /** @var int The time in ms the shop object should wait until the next request. */ - 53: public static $NEXT_RESPONSE_WAIT_TIME = 600; + 52: /** @var boolean|null You use https or http? Default is true. */ + 53: private static $ISSSL = true; 54: - 55: /** - 56: * The constructor for the main class. - 57: * - 58: * @author David Pauli <contact@david-pauli.de> - 59: * @since 0.0.0 - 60: * @since 0.0.1 Use disconnect function on wrong parameters. - 61: * @api + 55: /** @var String|null The refered ePages ahop. */ + 56: private static $SHOP = null; + 57: + 58: /** + 59: * The constructor for the main class. + 60: * + 61: * @author David Pauli <contact@david-pauli.de> 62: * @param String $host The epages host to connect. 63: * @param String $shop The refered ePages shop. 64: * @param String $authToken The authentificaton token to connect via REST. 65: * @param boolean $isssl True, if you use SSL, false if not. Default value is true. - 66: */ - 67: public static function connect($host, $shop, $authToken, $isssl) { - 68: - 69: // check parameter - 70: if (!InputValidator::isHost($host) || - 71: !InputValidator::isShop($shop)) { - 72: self::disconnect(); - 73: return false; - 74: } - 75: - 76: self::$HOST = $host; - 77: self::$SHOP = $shop; - 78: self::$ISSSL = $isssl; - 79: self::$AUTHTOKEN = $authToken; - 80: self::$ISCONNECTED = true; - 81: - 82: return true; - 83: } - 84: - 85: /** - 86: * This function prints the status of the REST client in a FORCE Logger message. - 87: * - 88: * @author David Pauli <contact@david-pauli.de> - 89: * @since 0.0.0 - 90: * @since 0.1.1 Echo the object itself to see all values setted. - 91: * @deprecated Echo the object itself to see all values setted. - 92: */ - 93: public static function printStatus() { + 66: * @since 0.0.0 + 67: * @since 0.0.1 Use disconnect function on wrong parameters. + 68: * @since 0.1.2 Throw warning with wrong parameters. + 69: * @since 0.1.2 Add error reporting. + 70: */ + 71: public static function connect($host, $shop, $authToken = null, $isssl = null) { + 72: + 73: self::errorReset(); + 74: + 75: // check parameters + 76: if (!InputValidator::isHost($host) || + 77: !InputValidator::isShop($shop)) { + 78: + 79: Logger::warning("ep6\RESTClient\nHost (" . $host . ") or Shop (" . $shop . ") are not valid."); + 80: self::disconnect(); + 81: $error = !InputValidator::isHost($host) ? "RESTC-1" : "RESTC-2"; + 82: self::errorSet($error); + 83: return false; + 84: } + 85: + 86: self::$HOST = $host; + 87: self::$SHOP = $shop; + 88: self::$ISSSL = $isssl; + 89: self::$AUTHTOKEN = $authToken; + 90: self::$ISCONNECTED = true; + 91: + 92: return true; + 93: } 94: - 95: Logger::force(self); - 96: } - 97: - 98: /** - 99: * This send function sends a special command to the REST server. -100: * -101: * @author David Pauli <contact@david-pauli.de> -102: * @since 0.0.0 -103: * @api -104: * @param String command The path which is requested in the REST client. -105: * @param String locale The localization to get. -106: * @param mixed[] postfields Add specific parameters to the REST server. -107: * @return String The returned JSON object or null if something goes wrong. -108: */ -109: public static function sendWithLocalization($command, $locale, $postfields = array()) { + 95: /** + 96: * Disconnects and deletes all configuration data. + 97: * + 98: * @author David Pauli <contact@david-pauli.de> + 99: * @since 0.0.0 +100: * @since 0.1.2 Add error reporting. +101: */ +102: public static function disconnect() { +103: +104: self::errorReset(); +105: self::$HOST = ""; +106: self::$SHOP = ""; +107: self::$AUTHTOKEN = null; +108: self::$ISCONNECTED = false; +109: self::$ISSSL = true; 110: -111: // cheeck parameters -112: if (!InputValidator::isLocale($locale)) { -113: return null; -114: } -115: return self::send($command . "?locale=" . $locale, $postfields); -116: } -117: -118: /** -119: * This send function sends a special command to the REST server with additional parameter. -120: * -121: * @author David Pauli <contact@david-pauli.de> -122: * @since 0.0.0 -123: * @since 0.0.1 Use HTTPRequestMethod enum. -124: * @since 0.1.0 Allow empty message body if the status code is 204. -125: * @api -126: * @param String command The path which is requested in the REST client. -127: * @param String[] postfields Add specific parameters to the REST server. -128: * @return mixed[] The returned elements as array. -129: */ -130: public static function send($command, $postfields = array()) { +111: return true; +112: } +113: +114: /** +115: * This send function sends a special command to the REST server with additional parameter. +116: * +117: * @author David Pauli <contact@david-pauli.de> +118: * @param String command The path which is requested in the REST client. +119: * @param String[] postfields Add specific parameters to the REST server. +120: * @return mixed[] The returned elements as array. +121: * @since 0.0.0 +122: * @since 0.0.1 Use HTTPRequestMethod enum. +123: * @since 0.1.0 Allow empty message body if the status code is 204. +124: * @since 0.1.2 Restructure the logging message and fix the PATCH call. +125: * @since 0.1.2 Add error reporting. +126: */ +127: public static function send($command, $postfields = array()) { +128: +129: self::errorReset(); +130: $JSONpostfield = ""; 131: 132: if (!InputValidator::isRESTCommand($command) || -133: !self::$ISCONNECTED || -134: !InputValidator::isArray($postfields)) { -135: return null; -136: } -137: -138: $protocol = self::$ISSSL ? "https" : "http"; -139: $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command; +133: !InputValidator::isArray($postfields)) { +134: +135: Logger::warning("ep6\RESTClient\nCommand (" . $command . ") or postfields (" . $postfields . ") are not valid."); +136: $error = !InputValidator::isRESTCommand($command) ? "RESTC-4" : "RESTC-5"; +137: self::errorSet($error); +138: return null; +139: } 140: -141: $headers = array( -142: "Accept: " . self::HTTP_ACCEPT, -143: "Content-Type: " . self::HTTP_CONTENT_TYPE); -144: -145: if (InputValidator::isAuthToken(self::$AUTHTOKEN)) { -146: array_push($headers, "Authorization: Bearer " . self::$AUTHTOKEN); -147: } -148: -149: $curl = curl_init($url); +141: if (!self::$ISCONNECTED) { +142: +143: Logger::warning("ep6\RESTClient\nClient is not connected."); +144: self::errorSet("RESTC-6"); +145: return null; +146: } +147: +148: $protocol = self::$ISSSL ? "https" : "http"; +149: $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command; 150: -151: curl_setopt($curl, CURLOPT_FAILONERROR, 1); // show full errors -152: curl_setopt($curl, CURLOPT_FORBID_REUSE, 0); // connection can be opened -153: curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0); // no new connection required -154: curl_setopt($curl, CURLOPT_NOBODY, 0); // show body -155: curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // get response as string -156: curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); // no connection timeout -157: curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0); // no connection timeout -158: curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE); // cURL will choose the http version -159: curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER); // understand ipv4 and ipv6 -160: -161: if (self::$ISSSL) { -162: curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // don't check the peer ssl cerrificate -163: curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); -164: curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); -165: curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT); // default ssl version -166: } -167: else { -168: curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); -169: curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); -170: } -171: -172: switch (self::$HTTP_REQUEST_METHOD) { -173: case HTTPRequestMethod::GET: -174: curl_setopt($curl, CURLOPT_HTTPGET, 1); -175: break; -176: case HTTPRequestMethod::POST: -177: $JSONpostfield = JSONHandler::createJSON($postfields); -178: curl_setopt($curl, CURLOPT_POST, 1); -179: curl_setopt($curl, CURLOPT_POSTREDIR, 0); // don't post on redirects -180: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); -181: break; -182: case HTTPRequestMethod::PUT: -183: $JSONpostfield = JSONHandler::createJSON($postfields); -184: array_push($headers, "Content-Length: " . strlen($JSONpostfield)); -185: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); -186: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); -187: break; -188: case HTTPRequestMethod::DELETE: -189: $JSONpostfield = JSONHandler::createJSON($postfields); -190: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); -191: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); -192: break; -193: case HTTPRequestMethod::PATCH: -194: $JSONpostfield = JSONHandler::createJSON($postfields); -195: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); +151: $headers = array( +152: "Accept: " . self::HTTP_ACCEPT, +153: "Content-Type: " . self::HTTP_CONTENT_TYPE); +154: +155: if (InputValidator::isAuthToken(self::$AUTHTOKEN)) { +156: +157: array_push($headers, "Authorization: Bearer " . self::$AUTHTOKEN); +158: } +159: +160: $curl = curl_init($url); +161: +162: curl_setopt($curl, CURLOPT_FAILONERROR, 1); // show full errors +163: curl_setopt($curl, CURLOPT_FORBID_REUSE, 0); // connection can be opened +164: curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0); // no new connection required +165: curl_setopt($curl, CURLOPT_NOBODY, 0); // show body +166: curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // get response as string +167: curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); // no connection timeout +168: curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0); // no connection timeout +169: curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE); // cURL will choose the http version +170: curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER); // understand ipv4 and ipv6 +171: curl_setopt($curl, CURLINFO_HEADER_OUT, 1); // save the header in the log +172: +173: if (self::$ISSSL) { +174: +175: curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // don't check the peer ssl cerrificate +176: curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); +177: curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); +178: curl_setopt($curl, CURLOPT_SSLVERSION, 0); // default ssl version +179: } +180: else { +181: +182: curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); +183: curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); +184: } +185: +186: switch (self::$HTTP_REQUEST_METHOD) { +187: +188: case HTTPRequestMethod::GET: +189: curl_setopt($curl, CURLOPT_HTTPGET, 1); +190: break; +191: +192: case HTTPRequestMethod::POST: +193: $JSONpostfield = JSONHandler::createJSON($postfields); +194: curl_setopt($curl, CURLOPT_POST, 1); +195: curl_setopt($curl, CURLOPT_POSTREDIR, 0); // don't post on redirects 196: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); 197: break; -198: } -199: -200: curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); -201: -202: $response = curl_exec($curl); -203: $info = curl_getinfo($curl); -204: $error = curl_error($curl); -205: curl_close($curl); -206: -207: $logMessage = self::$HTTP_REQUEST_METHOD . " " . $info["url"] . "<br/>" -208: . "<strong>Response</strong>: " . $info["http_code"] . ": <pre>" . htmlspecialchars($response) . "</pre><br/>" -209: . "<strong>Content-Type</strong>: " . $info["content_type"] . "<br/>" -210: . "<strong>Size</strong> (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes<br/>" -211: . "<strong>Time</strong> (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds<br/>"; -212: Logger::notify("<strong>HTTP-SEND</strong>:<br/>" . $logMessage); -213: -214: // if message body is empty this is allowed with 204 -215: if (!$response && $info["http_code"]!="204") { -216: Logger::error("Error with send REST client: " .$error); -217: return null; -218: } -219: elseif (!in_array($info["http_code"], array("200", "201", "204"))) { -220: Logger::warning("Get wrong response: " . $info["http_code"]); -221: return null; -222: } -223: -224: return JSONHandler::parseJSON($response); -225: } -226: -227: /** -228: * Sets another request method. -229: * -230: * @author David Pauli <contact@david-pauli.de> -231: * @since 0.0.0 -232: * @since 0.1.0 Use HTTPRequestMethod enum. -233: * @api -234: * @param HTTPRequestMethod method The request method the REST client should use. -235: * @return boolean True, if it works, false if not. -236: */ -237: public static function setRequestMethod($method) { -238: if (!InputValidator::isRequestMethod($method)) { -239: return false; -240: } -241: self::$HTTP_REQUEST_METHOD = $method; -242: return true; -243: } +198: +199: case HTTPRequestMethod::PUT: +200: $JSONpostfield = JSONHandler::createJSON($postfields); +201: array_push($headers, "Content-Length: " . strlen($JSONpostfield)); +202: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); +203: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); +204: break; +205: +206: case HTTPRequestMethod::DELETE: +207: $JSONpostfield = JSONHandler::createJSON($postfields); +208: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); +209: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); +210: break; +211: +212: case HTTPRequestMethod::PATCH: +213: $JSONpostfield = "[" . JSONHandler::createJSON($postfields) . "]"; +214: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); +215: curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield); +216: break; +217: } +218: +219: curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); +220: +221: $response = curl_exec($curl); +222: $info = curl_getinfo($curl); +223: $error = curl_error($curl); +224: curl_close($curl); +225: +226: $logMessage = "Request:\n" +227: . "Parameters: " . $JSONpostfield . "\n" +228: . $info["request_header"] +229: . "Response:\n" +230: . $info["http_code"] . ": " . $response . "\n" +231: . "Content-Type: " . $info["content_type"] . "\n" +232: . "Size (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes\n" +233: . "Time (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds\n"; +234: Logger::notify("ep6\RESTClient:\n" . $logMessage); +235: +236: // if message body is empty this is allowed with 204 +237: if (!$response && $info["http_code"] != "204") { +238: +239: Logger::error("ep6\RESTClient\nError with send REST client: " . $error); +240: self::errorSet("RESTC-7"); +241: return null; +242: } +243: elseif (!in_array($info["http_code"], array("200", "201", "204"))) { 244: -245: /** -246: * Disconnects and deletes all configuration data. -247: * -248: * @author David Pauli <contact@david-pauli.de> -249: * @since 0.0.0 -250: * @api -251: */ -252: public static function disconnect() { -253: -254: self::$HOST = ""; -255: self::$SHOP = ""; -256: self::$AUTHTOKEN = null; -257: self::$ISCONNECTED = false; -258: self::$ISSSL = true; -259: return true; -260: } -261: -262: /** -263: * Change the time to wait with the next request. -264: * -265: * @author David Pauli <contact@david-pauli.de> -266: * @since 0.1.1 -267: * @param int time The time in ms every reload needs to wait until get new information. -268: * @return boolean True if the change works, false if not. -269: * @api -270: */ -271: public static function setRequestWaitTime($time) { -272: -273: if (!InputValidator::isRangedInt($time, 0)) { -274: return false; +245: Logger::warning("ep6\RESTClient\nGet wrong response: " . $info["http_code"]); +246: self::errorSet("RESTC-8"); +247: return null; +248: } +249: +250: return JSONHandler::parseJSON($response); +251: } +252: +253: /** +254: * This send function sends a special command to the REST server. +255: * +256: * @author David Pauli <contact@david-pauli.de> +257: * @param String command The path which is requested in the REST client. +258: * @param String locale The localization to get. +259: * @param mixed[] postfields Add specific parameters to the REST server. +260: * @return String The returned JSON object or null if something goes wrong. +261: * @since 0.0.0 +262: * @since 0.1.2 Throw warning with wrong parameters. +263: * @since 0.1.2 Add error reporting. +264: */ +265: public static function sendWithLocalization($command, $locale, $postfields = array()) { +266: +267: self::errorReset(); +268: +269: // check parameters +270: if (!InputValidator::isLocale($locale)) { +271: +272: Logger::warning("ep6\RESTClient\nLocale (" . $locale . ") is not valid."); +273: self::errorSet("RESTC-3"); +274: return null; 275: } 276: -277: self::$NEXT_RESPONSE_WAIT_TIME = $time; -278: return true; -279: } -280: } -281: -282: /** -283: * The HTTP request 'enum'. -284: * -285: * This are the possible HTTP request methods.. -286: * -287: * @author David Pauli <contact@david-pauli.de> -288: * @since 0.0.1 -289: * @package ep6 -290: * @subpackage Util\RESTClient -291: */ -292: abstract class HTTPRequestMethod { -293: /** @var String Use this for a GET request. **/ -294: const GET = "GET"; -295: /** @var String Use this for a POST request. **/ -296: const POST = "POST"; -297: /** @var String Use this for a PUT request. **/ -298: const PUT = "PUT"; -299: /** @var String Use this for a DELETE request. **/ -300: const DELETE = "DELETE"; -301: /** @var String Use this for a PATCH request. **/ -302: const PATCH = "PATCH"; -303: } -304: -305: ?> +277: return self::send($command . "?locale=" . $locale, $postfields); +278: } +279: +280: /** +281: * Sets another request method. +282: * +283: * @author David Pauli <contact@david-pauli.de> +284: * @param HTTPRequestMethod method The request method the REST client should use. +285: * @return boolean True, if it works, false if not. +286: * @since 0.0.0 +287: * @since 0.1.0 Use HTTPRequestMethod enum. +288: * @since 0.1.2 Throw warning with wrong parameters. +289: * @since 0.1.2 Add error reporting. +290: */ +291: public static function setRequestMethod($method) { +292: +293: self::errorReset(); +294: +295: if (!InputValidator::isRequestMethod($method)) { +296: +297: Logger::warning("ep6\RESTClient\nRequest method (" . $method . ") is not valid."); +298: self::errorSet("RESTC-9"); +299: return false; +300: } +301: +302: self::$HTTP_REQUEST_METHOD = $method; +303: return true; +304: } +305: +306: /** +307: * Change the time to wait with the next request. +308: * +309: * @author David Pauli <contact@david-pauli.de> +310: * @param int time The time in ms every reload needs to wait until get new information. +311: * @return boolean True if the change works, false if not. +312: * @since 0.1.1 +313: * @since 0.1.2 Throw warning with wrong parameters. +314: * @since 0.1.2 Add error reporting. +315: */ +316: public static function setRequestWaitTime($time) { +317: +318: self::errorReset(); +319: +320: if (!InputValidator::isRangedInt($time, 0)) { +321: +322: Logger::warning("ep6\RESTClient\nRequest time (" . $time . ") is not valid."); +323: self::errorSet("RESTC-10"); +324: return false; +325: } +326: +327: self::$NEXT_RESPONSE_WAIT_TIME = $time; +328: +329: return true; +330: } +331: } +332: ?> - + diff --git a/doc/source-class-ep6.RightsOfWithdrawalInformation.html b/doc/source-class-ep6.RightsOfWithdrawalInformation.html index a5ea861..d0e4bb2 100644 --- a/doc/source-class-ep6.RightsOfWithdrawalInformation.html +++ b/doc/source-class-ep6.RightsOfWithdrawalInformation.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,52 +101,37 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the rights of withdrawal class.
    + 3:  * This file represents the Rights Of Withdrawal class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
      7:  */
      8: namespace ep6;
      9: /**
    -10:  * This class is needed for use the information coming from rights of withdrawal.
    +10:  * This class is needed for use the information coming from Rights Of Withdrawal.
     11:  *
     12:  * @author David Pauli <contact@david-pauli.de>
    -13:  * @since 0.0.0
    -14:  * @since 0.1.1 This object is now echoable.
    -15:  * @since 0.1.1 Unstatic every attributes.
    -16:  * @package ep6
    -17:  * @subpackage Shopobjects\Information
    -18:  * @see InformationTrait This trait has all information needed objects.
    -19:  */
    -20: class RightsOfWithdrawalInformation {
    -21: 
    -22:     use InformationTrait;
    +13:  * @package ep6
    +14:  * @see InformationTrait This trait has all information needed objects.
    +15:  * @see ErrorReporting This trait gives the error reporting functionality.
    +16:  * @since 0.0.0
    +17:  * @since 0.1.1 This object is now echoable.
    +18:  * @since 0.1.1 Unstatic every attributes.
    +19:  * @since 0.1.2 Add error reporting.
    +20:  * @subpackage Shopobjects\Information
    +21:  */
    +22: class RightsOfWithdrawalInformation {
     23: 
    -24:     /** @var String The REST path for rights of withdrawal. */
    -25:     const RESTPATH = "legal/rights-of-withdrawal";
    -26: 
    -27:     /** @var int Timestamp in ms when the next request needs to be done. */
    -28:     private $NEXT_REQUEST_TIMESTAMP = 0;
    -29: 
    -30:     /**
    -31:      * Prints the Information object as a string.
    -32:      *
    -33:      * This function returns the setted values of the Information object.
    -34:      *
    -35:      * @author David Pauli <contact@david-pauli.de>
    -36:      * @since 0.1.1
    -37:      * @return String The Information as a string.
    -38:      */
    -39:     public function __toString() {
    -40: 
    -41:         return "<strong>Name:</strong> " . $this->NAME . "<br/>" .
    -42:                 "<strong>Navigation caption:</strong> " . $this->NAVIGATIONCAPTION . "<br/>" .
    -43:                 "<strong>Description:</strong> " . $this->DESCRIPTION . "<br/>" .
    -44:                 "<strong>Next allowed request time:</strong> " . $this->NEXT_REQUEST_TIMESTAMP . "<br/>";
    -45:     }
    -46: 
    -47: }
    -48: ?>
    +24: use Information, ErrorReporting; +25: +26: /** @var String The REST path for rights of withdrawal. */ +27: const RESTPATH = "legal/rights-of-withdrawal"; +28: +29: /** @var int Timestamp in ms when the next request needs to be done. */ +30: private $NEXT_REQUEST_TIMESTAMP = 0; +31: +32: } +33: ?> - + diff --git a/doc/source-class-ep6.ShippingInformation.html b/doc/source-class-ep6.ShippingInformation.html index 9e54b91..ada8430 100644 --- a/doc/source-class-ep6.ShippingInformation.html +++ b/doc/source-class-ep6.ShippingInformation.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,52 +101,37 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the shipping information class.
    + 3:  * This file represents the Shipping Information class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
      7:  */
      8: namespace ep6;
      9: /**
    -10:  * This class is needed for the shipping information in the shop.
    +10:  * This class is needed for the Shipping Information in the shop.
     11:  *
     12:  * @author David Pauli <contact@david-pauli.de>
    -13:  * @since 0.0.0
    -14:  * @since 0.1.1 This object is now echoable.
    -15:  * @since 0.1.1 Unstatic every attributes.
    -16:  * @package ep6
    -17:  * @subpackage Shopobjects\Information
    -18:  * @see InformationTrait This trait has all information needed objects.
    -19:  */
    -20: class ShippingInformation {
    -21: 
    -22:     use InformationTrait;
    +13:  * @package ep6
    +14:  * @see InformationTrait This trait has all information needed objects.
    +15:  * @see ErrorReporting This trait gives the error reporting functionality.
    +16:  * @since 0.0.0
    +17:  * @since 0.1.1 This object is now echoable.
    +18:  * @since 0.1.1 Unstatic every attributes.
    +19:  * @since 0.1.2 Add error reporting.
    +20:  * @subpackage Shopobjects\Information
    +21:  */
    +22: class ShippingInformation {
     23: 
    -24:     /** @var String The REST path for shipping information. */
    -25:     const RESTPATH = "legal/shipping-information";
    -26: 
    -27:     /** @var int Timestamp in ms when the next request needs to be done. */
    -28:     private $NEXT_REQUEST_TIMESTAMP = 0;
    -29: 
    -30:     /**
    -31:      * Prints the Information object as a string.
    -32:      *
    -33:      * This function returns the setted values of the Information object.
    -34:      *
    -35:      * @author David Pauli <contact@david-pauli.de>
    -36:      * @since 0.1.1
    -37:      * @return String The Information as a string.
    -38:      */
    -39:     public function __toString() {
    -40: 
    -41:         return "<strong>Name:</strong> " . $this->NAME . "<br/>" .
    -42:                 "<strong>Navigation caption:</strong> " . $this->NAVIGATIONCAPTION . "<br/>" .
    -43:                 "<strong>Description:</strong> " . $this->DESCRIPTION . "<br/>" .
    -44:                 "<strong>Next allowed request time:</strong> " . $this->NEXT_REQUEST_TIMESTAMP . "<br/>";
    -45:     }
    -46: 
    -47: }
    -48: ?>
    +24: use Information, ErrorReporting; +25: +26: /** @var String The REST path for shipping information. */ +27: const RESTPATH = "legal/shipping-information"; +28: +29: /** @var int Timestamp in ms when the next request needs to be done. */ +30: private $NEXT_REQUEST_TIMESTAMP = 0; +31: +32: } +33: ?> - + diff --git a/doc/source-class-ep6.Shop.html b/doc/source-class-ep6.Shop.html index 096e1a5..f155ffe 100644 --- a/doc/source-class-ep6.Shop.html +++ b/doc/source-class-ep6.Shop.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -106,105 +110,105 @@

    Traits

    9: # include framework configuration 10: require_once(__DIR__ . "/configuration/config.php"); 11: # include helpful objects, all are used in a static way - 12: require_once(__DIR__ . "/util/InputValidator.class.php"); - 13: require_once(__DIR__ . "/util/JSONHandler.class.php"); - 14: require_once(__DIR__ . "/util/Logger.class.php"); - 15: require_once(__DIR__ . "/util/RESTClient.class.php"); - 16: # include shopobjects - 17: require_once(__DIR__ . "/shopobjects/Locales.class.php"); - 18: require_once(__DIR__ . "/shopobjects/Currencies.class.php"); - 19: require_once(__DIR__ . "/shopobjects/information/InformationTrait.class.php"); - 20: require_once(__DIR__ . "/shopobjects/information/ContactInformation.class.php"); - 21: require_once(__DIR__ . "/shopobjects/information/PrivacyPolicyInformation.class.php"); - 22: require_once(__DIR__ . "/shopobjects/information/RightsOfWithdrawalInformation.class.php"); - 23: require_once(__DIR__ . "/shopobjects/information/TermsAndConditionInformation.class.php"); - 24: require_once(__DIR__ . "/shopobjects/information/ShippingInformation.class.php"); - 25: require_once(__DIR__ . "/shopobjects/product/ProductFilter.class.php"); - 26: require_once(__DIR__ . "/shopobjects/product/Product.class.php"); - 27: require_once(__DIR__ . "/shopobjects/product/ProductSlideshow.class.php"); - 28: require_once(__DIR__ . "/shopobjects/product/ProductAttribute.class.php"); - 29: require_once(__DIR__ . "/shopobjects/image/Image.class.php"); + 12: require_once(__DIR__ . "/util/ErrorReporting.trait.php"); + 13: require_once(__DIR__ . "/util/HTTPRequestMethod.enum.php"); + 14: require_once(__DIR__ . "/util/InputValidator.class.php"); + 15: require_once(__DIR__ . "/util/JSONHandler.class.php"); + 16: require_once(__DIR__ . "/util/Logger.class.php"); + 17: require_once(__DIR__ . "/util/LogLevel.enum.php"); + 18: require_once(__DIR__ . "/util/LogOutput.enum.php"); + 19: require_once(__DIR__ . "/util/RESTClient.class.php"); + 20: # include shopobjects + 21: require_once(__DIR__ . "/shopobjects/Currencies.class.php"); + 22: require_once(__DIR__ . "/shopobjects/Locales.class.php"); + 23: require_once(__DIR__ . "/shopobjects/image/Image.class.php"); + 24: require_once(__DIR__ . "/shopobjects/information/Information.trait.php"); + 25: require_once(__DIR__ . "/shopobjects/information/ContactInformation.class.php"); + 26: require_once(__DIR__ . "/shopobjects/information/PrivacyPolicyInformation.class.php"); + 27: require_once(__DIR__ . "/shopobjects/information/RightsOfWithdrawalInformation.class.php"); + 28: require_once(__DIR__ . "/shopobjects/information/ShippingInformation.class.php"); + 29: require_once(__DIR__ . "/shopobjects/information/TermsAndConditionInformation.class.php"); 30: require_once(__DIR__ . "/shopobjects/price/Price.class.php"); 31: require_once(__DIR__ . "/shopobjects/price/PriceWithQuantity.class.php"); - 32: - 33: /** - 34: * This is the epages 6 shop object. - 35: * - 36: * @author David Pauli <contact@david-pauli.de> - 37: * @since 0.0.0 - 38: * @since 0.1.0 Configure the Locale and Currency to make REST calls. - 39: * @since 0.1.1 Now the shop can be printed via echo. - 40: * @since 0.1.1 Save their own shop credentials and use Information objects unstatic. - 41: * @package ep6 - 42: * @example examples\connectingShop.php Create a new epage 6 shop object and disconnect. - 43: */ - 44: class Shop { - 45: - 46: /** @var ContactInformation|null The contact information object. */ - 47: private $contactInformation = null; - 48: - 49: /** @var PrivacyPolicyInformation|null The privacy policy information object. */ - 50: private $privacyPolicyInformation = null; - 51: - 52: /** @var RightsOfWithdrawalInformation|null The rights of withdrawal information object. */ - 53: private $rightsOfWithdrawalInformation = null; + 32: require_once(__DIR__ . "/shopobjects/price/ProductPrice.class.php"); + 33: require_once(__DIR__ . "/shopobjects/price/ProductPriceType.enum.php"); + 34: require_once(__DIR__ . "/shopobjects/price/ProductPriceWithQuantity.class.php"); + 35: require_once(__DIR__ . "/shopobjects/product/Product.class.php"); + 36: require_once(__DIR__ . "/shopobjects/product/ProductAttribute.class.php"); + 37: require_once(__DIR__ . "/shopobjects/product/ProductFilter.class.php"); + 38: require_once(__DIR__ . "/shopobjects/product/ProductSlideshow.class.php"); + 39: + 40: /** + 41: * This is the epages 6 shop object. + 42: * + 43: * @author David Pauli <contact@david-pauli.de> + 44: * @package ep6 + 45: * @since 0.0.0 + 46: * @since 0.1.0 Configure the Locale and Currency to make REST calls. + 47: * @since 0.1.1 Now the shop can be printed via echo. + 48: * @since 0.1.1 Save their own shop credentials and use Information objects unstatic. + 49: * @since 0.1.2 Add error reporting. + 50: */ + 51: class Shop { + 52: + 53: use ErrorReporting; 54: - 55: /** @var ShippingInformation|null The shipping information object. */ - 56: private $shippingInformation = null; + 55: /** @var String|null The authentification token (access token). */ + 56: private $authToken = null; 57: - 58: /** @var String|null The ePages host to connect. */ - 59: private $host = null; + 58: /** @var ContactInformation|null The contact information object. */ + 59: private $contactInformation = null; 60: - 61: /** @var String|null The refered ePages ahop. */ - 62: private $shop = null; + 61: /** @var String|null The ePages host to connect. */ + 62: private $host = null; 63: - 64: /** @var String|null The authentification token (access token). */ - 65: private $authToken = null; + 64: /** @var boolean|null You use https or http? Default is true. */ + 65: private $isssl = true; 66: - 67: /** @var boolean|null You use https or http? Default is true. */ - 68: private $isssl = true; + 67: /** @var PrivacyPolicyInformation|null The privacy policy information object. */ + 68: private $privacyPolicyInformation = null; 69: - 70: /** - 71: * The constructor for the shop class. - 72: * - 73: * @author David Pauli <contact@david-pauli.de> - 74: * @since 0.0.0 - 75: * @since 0.1.1 Save the own login credentials. - 76: * @api - 77: * @param String $host The ePages host to connect. - 78: * @param String $shop The refered ePages shop. - 79: * @param String $authToken The authentificaton token to connect via REST. - 80: * @param boolean $isssl True, if you use SSL, false if not. Default value is true. - 81: * @source 2 1 Calls the REST client and connect. - 82: */ - 83: function __construct($host, $shop, $authToken, $isssl = true) { - 84: - 85: if (!InputValidator::isHost($host) || - 86: !InputValidator::isShop($shop)) { - 87: return; - 88: } - 89: - 90: $this->host = $host; - 91: $this->shop = $shop; - 92: $this->authToken = $authToken; - 93: $this->isssl = $isssl; - 94: - 95: RESTClient::connect($this->host, $this->shop, $this->authToken, $this->isssl); - 96: } - 97: - 98: /** - 99: * Use this shop from now. -100: * -101: * @author David Pauli <contact@david-pauli.de> -102: * @since 0.1.1 -103: * @api -104: */ -105: function useShop() { -106: -107: if (InputValidator::isEmpty($this->host) || -108: InputValidator::isEmpty($this->shop)) { -109: RESTClient::disconnect($this->host, $this->shop, $this->authToken, $this->isssl); -110: } + 70: /** @var RightsOfWithdrawalInformation|null The rights of withdrawal information object. */ + 71: private $rightsOfWithdrawalInformation = null; + 72: + 73: /** @var ShippingInformation|null The shipping information object. */ + 74: private $shippingInformation = null; + 75: + 76: /** @var String|null The refered ePages ahop. */ + 77: private $shop = null; + 78: + 79: /** @var TermsAndConditionInformation|null The terms and condition information object. */ + 80: private $termsAndConditionInformation = null; + 81: + 82: /** + 83: * The constructor for the shop class. + 84: * + 85: * @author David Pauli <contact@david-pauli.de> + 86: * @param String $host The ePages host to connect. + 87: * @param String $shop The refered ePages shop. + 88: * @param String $authToken The authentificaton token to connect via REST. + 89: * @param boolean $isssl True, if you use SSL, false if not. Default value is true. + 90: * @since 0.0.0 + 91: * @since 0.1.1 Save the own login credentials. + 92: * @since 0.1.2 Add error reporting. + 93: */ + 94: function __construct($host, $shop, $authToken, $isssl = true) { + 95: + 96: if (!InputValidator::isHost($host) || + 97: !InputValidator::isShop($shop)) { + 98: + 99: Logger::warning("ep6\Shop\nHost (" . $host . ") or Shop (" . $shop . ") are not valid."); +100: $error = !InputValidator::isHost($host) ? "S-1" : "S-2"; +101: self::setError($error); +102: return; +103: } +104: +105: $this->host = $host; +106: $this->shop = $shop; +107: $this->authToken = $authToken; +108: $this->isssl = $isssl; +109: +110: RESTClient::connect($this->host, $this->shop, $this->authToken, $this->isssl); 111: } 112: 113: /** @@ -213,246 +217,290 @@

    Traits

    116: * @author David Pauli <contact@david-pauli.de> 117: * @since 0.0.0 118: * @since 0.1.1 Unset the own shop credentials. -119: * @api -120: * @source 2 1 Disconnect the REST client. -121: */ -122: function __destruct() { -123: -124: $this->host = null; -125: $this->shop = null; -126: $this->authToken = null; -127: $this->isssl = null; -128: RESTClient::disconnect(); -129: } -130: -131: /** -132: * Prints the connection status via "FORCE". -133: * -134: * This function will print the current values of the REST client. -135: * -136: * @author David Pauli <contact@david-pauli.de> -137: * @since 0.0.0 -138: * @since 0.1.1 Echo the object itself to see all values setted. -139: * @deprecated Echo the object itself to see all values setted. +119: */ +120: function __destruct() { +121: +122: $this->host = null; +123: $this->shop = null; +124: $this->authToken = null; +125: $this->isssl = null; +126: +127: RESTClient::disconnect(); +128: } +129: +130: /** +131: * Deletes a product. +132: * +133: * This function try to deletes the product in the shop. It also unset the given Product object. +134: * +135: * @author David Pauli <contact@david-pauli.de> +136: * @param Product The product to delete. +137: * @return boolean True if the deletion works, false if not. +138: * @since 0.1.0 +139: * @since 0.1.2 Add error reporting. 140: */ -141: public function printStatus() { +141: public function deleteProduct(&$product) { 142: -143: Logger::force(RESTClient); -144: } -145: -146: /** -147: * Returns the default localization. -148: * -149: * @api -150: * @author David Pauli <contact@david-pauli.de> -151: * @since 0.0.0 -152: * @return String|null Default localization or null if the REST call does fail. -153: */ -154: public function getDefaultLocales() { -155: -156: return Locales::getDefault(); -157: } -158: -159: /** -160: * Returns all localizations. -161: * -162: * @api -163: * @author David Pauli <contact@david-pauli.de> -164: * @since 0.0.0 -165: * @return mixed[]|null All localizations in an array or null if the REST call does fail. -166: */ -167: public function getLocales() { -168: -169: return Locales::getItems(); -170: } +143: self::errorReset(); +144: +145: if ($product->delete()) { +146: +147: $product = null; +148: return true; +149: } +150: +151: Logger::warning("ep6\Shop\nCan't delete product: " . $product); +152: self::errorSet("S-5"); +153: +154: return false; +155: } +156: +157: /** +158: * Get the contact information. +159: * +160: * @author David Pauli <contact@david-pauli.de> +161: * @return ContactInformation|null The contact information of the shop or null if the REST call will fail. +162: * @since 0.0.0 +163: * @since 0.1.1 Create an unstatic Information object. +164: * @since 0.1.2 Add error reporting. +165: */ +166: public function getContactInformation() { +167: +168: self::errorReset(); +169: +170: if ($this->contactInformation==null) { 171: -172: /** -173: * Returns the default currencies. -174: * -175: * @api -176: * @author David Pauli <contact@david-pauli.de> -177: * @since 0.0.0 -178: * @return String|null Default currencies or null if the REST call does fail. -179: */ -180: public function getDefaultCurrencies() { -181: -182: return Currencies::getDefault(); -183: } -184: -185: /** -186: * Returns all currencies. -187: * -188: * @api -189: * @author David Pauli <contact@david-pauli.de> -190: * @since 0.0.0 -191: * @return mixed[]|null All currencies in an array or null if the REST call will fail. -192: */ -193: public function getCurrencies() { -194: -195: return Currencies::getItems(); -196: } -197: -198: /** -199: * Returns configured Locale. -200: * -201: * @api -202: * @author David Pauli <contact@david-pauli.de> -203: * @since 0.1.0 -204: * @return String|null The Locale which is configured for REST calls. -205: */ -206: public function getLocale() { -207: -208: return Locales::getLocale(); -209: } -210: -211: /** -212: * Set configured Locale. -213: * -214: * @api -215: * @author David Pauli <contact@david-pauli.de> -216: * @since 0.1.0 -217: * @param String $locale The new used Locale. -218: * @return boolean True if set the Locale works, false if not. -219: */ -220: public function setLocale($locale) { -221: -222: return Locales::setLocale($locale); -223: } -224: -225: /** -226: * Returns configured Currency. -227: * -228: * @api -229: * @author David Pauli <contact@david-pauli.de> -230: * @since 0.1.0 -231: * @return String|null The Currency which is configured for REST calls. -232: */ -233: public function getCurrency() { -234: -235: return Currencies::getCurrency(); -236: } -237: -238: /** -239: * Set configured Currency. -240: * -241: * @api -242: * @author David Pauli <contact@david-pauli.de> -243: * @since 0.1.0 -244: * @param String $locale The new used Locale. -245: * @return boolean True if set the Locale works, false if not. -246: */ -247: public function setCurrency($currency) { -248: -249: return Currencies::setCurrency($currency); -250: } -251: -252: /** -253: * Get the contact information. -254: * -255: * @api -256: * @author David Pauli <contact@david-pauli.de> -257: * @since 0.0.0 -258: * @since 0.1.1 Create an unstatic Information object. -259: * @return ContactInformation|null The contact information of the shop or null if the REST call will fail. -260: */ -261: public function getContactInformation() { -262: -263: if ($this->contactInformation==null) { -264: $this->contactInformation = new ContactInformation(); -265: } -266: return $this->contactInformation; -267: } -268: -269: /** -270: * Get the privacy policy information. -271: * -272: * @api -273: * @author David Pauli <contact@david-pauli.de> -274: * @since 0.0.0 -275: * @since 0.1.1 Create an unstatic Information object. -276: * @return PrivacyPolicyInformation|null The privacy policy information of the shop or null if the REST call will fail. -277: */ -278: public function getPrivacyPolicyInformation() { +172: $this->contactInformation = new ContactInformation(); +173: } +174: +175: return $this->contactInformation; +176: } +177: +178: /** +179: * Returns all currencies. +180: * +181: * @author David Pauli <contact@david-pauli.de> +182: * @return mixed[]|null All currencies in an array or null if the REST call will fail. +183: * @since 0.0.0 +184: * @since 0.1.2 Add error reporting. +185: */ +186: public function getCurrencies() { +187: +188: self::errorReset(); +189: return Currencies::getItems(); +190: } +191: +192: /** +193: * Returns configured Currency. +194: * +195: * @author David Pauli <contact@david-pauli.de> +196: * @return String|null The Currency which is configured for REST calls. +197: * @since 0.1.0 +198: * @since 0.1.2 Add error reporting. +199: */ +200: public function getCurrency() { +201: +202: self::errorReset(); +203: return Currencies::getCurrency(); +204: } +205: +206: /** +207: * Returns the default currencies. +208: * +209: * @author David Pauli <contact@david-pauli.de> +210: * @return String|null Default currencies or null if the REST call does fail. +211: * @since 0.0.0 +212: * @since 0.1.2 Add error reporting. +213: */ +214: public function getDefaultCurrencies() { +215: +216: self::errorReset(); +217: return Currencies::getDefault(); +218: } +219: +220: /** +221: * Returns the default localization. +222: * +223: * @author David Pauli <contact@david-pauli.de> +224: * @return String|null Default localization or null if the REST call does fail. +225: * @since 0.0.0 +226: * @since 0.1.2 Add error reporting. +227: */ +228: public function getDefaultLocales() { +229: +230: self::errorReset(); +231: return Locales::getDefault(); +232: } +233: +234: /** +235: * Returns configured Locale. +236: * +237: * @author David Pauli <contact@david-pauli.de> +238: * @return String|null The Locale which is configured for REST calls. +239: * @since 0.1.0 +240: * @since 0.1.2 Add error reporting. +241: */ +242: public function getLocale() { +243: +244: self::errorReset(); +245: return Locales::getLocale(); +246: } +247: +248: /** +249: * Returns all localizations. +250: * +251: * @author David Pauli <contact@david-pauli.de> +252: * @return mixed[]|null All localizations in an array or null if the REST call does fail. +253: * @since 0.0.0 +254: * @since 0.1.2 Add error reporting. +255: */ +256: public function getLocales() { +257: +258: self::errorReset(); +259: return Locales::getItems(); +260: } +261: +262: /** +263: * Get the privacy policy information. +264: * +265: * @author David Pauli <contact@david-pauli.de> +266: * @return PrivacyPolicyInformation|null The privacy policy information of the shop or null if the REST call will fail. +267: * @since 0.0.0 +268: * @since 0.1.1 Create an unstatic Information object. +269: * @since 0.1.2 Add error reporting. +270: */ +271: public function getPrivacyPolicyInformation() { +272: +273: self::errorReset(); +274: +275: if ($this->privacyPolicyInformation==null) { +276: +277: $this->privacyPolicyInformation = new PrivacyPolicyInformation(); +278: } 279: -280: if ($this->privacyPolicyInformation==null) { -281: $this->privacyPolicyInformation = new PrivacyPolicyInformation(); -282: } -283: return $this->privacyPolicyInformation; -284: } -285: -286: /** -287: * Get the rights of withdrawal information. -288: * -289: * @api -290: * @author David Pauli <contact@david-pauli.de> -291: * @since 0.0.0 -292: * @since 0.1.1 Create an unstatic Information object. -293: * @return RightsOfWithdrawalInformation|null The rights of withdrawal information of the shop or null if the REST call will fail. -294: */ -295: public function getRightsOfWithdrawalInformation() { -296: -297: if ($this->rightsOfWithdrawalInformation==null) { +280: return $this->privacyPolicyInformation; +281: } +282: +283: /** +284: * Get the rights of withdrawal information. +285: * +286: * @author David Pauli <contact@david-pauli.de> +287: * @return RightsOfWithdrawalInformation|null The rights of withdrawal information of the shop or null if the REST call will fail. +288: * @since 0.0.0 +289: * @since 0.1.1 Create an unstatic Information object. +290: * @since 0.1.2 Add error reporting. +291: */ +292: public function getRightsOfWithdrawalInformation() { +293: +294: self::errorReset(); +295: +296: if ($this->rightsOfWithdrawalInformation==null) { +297: 298: $this->rightsOfWithdrawalInformation = new RightsOfWithdrawalInformation(); 299: } -300: return $this->rightsOfWithdrawalInformation; -301: } -302: -303: /** -304: * Get the shipping information. -305: * -306: * @api +300: +301: return $this->rightsOfWithdrawalInformation; +302: } +303: +304: /** +305: * Get the shipping information. +306: * 307: * @author David Pauli <contact@david-pauli.de> -308: * @since 0.0.0 -309: * @since 0.1.1 Create an unstatic Information object. -310: * @return ShippingInformation|null The shipping information of the shop or null if the REST call fails. -311: */ -312: public function getShippingInformation() { -313: -314: if ($this->shippingInformation==null) { -315: $this->shippingInformation = new ShippingInformation(); -316: } -317: return $this->shippingInformation; -318: } -319: -320: /** -321: * Get the terms and condition information. -322: * -323: * @api -324: * @author David Pauli <contact@david-pauli.de> -325: * @since 0.0.0 -326: * @since 0.1.1 Create an unstatic Information object. -327: * @return TermsAndCondiditonInformation The terms and condition information of the shop or null if the REST call fails. -328: */ -329: public function getTermsAndConditionInformation() { -330: -331: if ($this->termsAndConditionInformation==null) { -332: $this->termsAndConditionInformation = new TermsAndConditionInformation(); -333: } -334: return $this->termsAndConditionInformation; -335: } -336: -337: /** -338: * Deletes a product. -339: * -340: * This function try to deletes the product in the shop. It also unset the given Product object. -341: * -342: * @api -343: * @author David Pauli <contact@david-pauli.de> -344: * @since 0.1.0 -345: * @param Product The product to delete. -346: * @return boolean True if the deletion works, false if not. -347: */ -348: public function deleteProduct(&$product) { -349: -350: if ($product->delete()) { -351: $product = null; -352: return true; -353: } -354: return false; -355: } +308: * @return ShippingInformation|null The shipping information of the shop or null if the REST call fails. +309: * @since 0.0.0 +310: * @since 0.1.1 Create an unstatic Information object. +311: * @since 0.1.2 Add error reporting. +312: */ +313: public function getShippingInformation() { +314: +315: self::errorReset(); +316: +317: if ($this->shippingInformation==null) { +318: +319: $this->shippingInformation = new ShippingInformation(); +320: } +321: +322: return $this->shippingInformation; +323: } +324: +325: /** +326: * Get the terms and condition information. +327: * +328: * @author David Pauli <contact@david-pauli.de> +329: * @return TermsAndCondiditonInformation The terms and condition information of the shop or null if the REST call fails. +330: * @since 0.0.0 +331: * @since 0.1.1 Create an unstatic Information object. +332: * @since 0.1.2 Add error reporting. +333: */ +334: public function getTermsAndConditionInformation() { +335: +336: self::errorReset(); +337: +338: if ($this->termsAndConditionInformation==null) { +339: +340: $this->termsAndConditionInformation = new TermsAndConditionInformation(); +341: } +342: +343: return $this->termsAndConditionInformation; +344: } +345: +346: /** +347: * Set configured Currency. +348: * +349: * @author David Pauli <contact@david-pauli.de> +350: * @param String $locale The new used Locale. +351: * @return boolean True if set the Locale works, false if not. +352: * @since 0.1.0 +353: * @since 0.1.2 Add error reporting. +354: */ +355: public function setCurrency($currency) { 356: -357: } -358: ?> +357: self::errorReset(); +358: return Currencies::setCurrency($currency); +359: } +360: +361: /** +362: * Set configured Locale. +363: * +364: * @author David Pauli <contact@david-pauli.de> +365: * @param String $locale The new used Locale. +366: * @return boolean True if set the Locale works, false if not. +367: * @since 0.1.0 +368: * @since 0.1.2 Add error reporting. +369: */ +370: public function setLocale($locale) { +371: +372: self::errorReset(); +373: return Locales::setLocale($locale); +374: } +375: +376: /** +377: * Use this shop from now. +378: * +379: * @author David Pauli <contact@david-pauli.de> +380: * @since 0.1.1 +381: * @since 0.1.2 Add error reporting. +382: */ +383: public function useShop() { +384: +385: self::errorReset(); +386: +387: if (InputValidator::isEmpty($this->host) || +388: InputValidator::isEmpty($this->shop)) { +389: +390: RESTClient::disconnect($this->host, $this->shop, $this->authToken, $this->isssl); +391: Logger::warning("ep6\Shop\nCan't use shop, because there no shop host and name configured."); +392: $error = InputValidator::isEmpty($this->host) ? "S-3" : "S-4"; +393: self::setError($error); +394: } +395: else { +396: +397: RESTClient::connect($this->host, $this->shop, $this->authToken, $this->isssl); +398: } +399: } +400: +401: } +402: ?> - + diff --git a/doc/source-class-ep6.TermsAndConditionInformation.html b/doc/source-class-ep6.TermsAndConditionInformation.html index c93ac75..73a6798 100644 --- a/doc/source-class-ep6.TermsAndConditionInformation.html +++ b/doc/source-class-ep6.TermsAndConditionInformation.html @@ -49,6 +49,9 @@

    Classes

  • ep6\Product
  • ep6\ProductAttribute
  • ep6\ProductFilter
  • +
  • ep6\ProductPrice
  • +
  • ep6\ProductPriceType
  • +
  • ep6\ProductPriceWithQuantity
  • ep6\ProductSlideshow
  • ep6\RESTClient
  • ep6\RightsOfWithdrawalInformation
  • @@ -60,7 +63,8 @@

    Classes

    Traits

    @@ -97,52 +101,37 @@

    Traits

     1: <?php
      2: /**
    - 3:  * This file represents the terms and condition information class.
    + 3:  * This file represents the Terms And Condition Information class.
      4:  *
      5:  * @author David Pauli <contact@david-pauli.de>
      6:  * @since 0.0.0
      7:  */
      8: namespace ep6;
      9: /**
    -10:  * This class is required for showing the information of terms and condition.
    +10:  * This class is required for showing the information of Terms And Condition.
     11:  *
     12:  * @author David Pauli <contact@david-pauli.de>
    -13:  * @since 0.0.0
    -14:  * @since 0.1.1 This object is now echoable.
    -15:  * @since 0.1.1 Unstatic every attributes.
    -16:  * @package ep6
    -17:  * @subpackage Shopobjects\Information
    -18:  * @see InformationTrait This trait has all information needed objects.
    -19:  */
    -20: class TermsAndConditionInformation {
    -21: 
    -22:     use InformationTrait;
    +13:  * @package ep6
    +14:  * @see InformationTrait This trait has all information needed objects.
    +15:  * @see ErrorReporting This trait gives the error reporting functionality.
    +16:  * @since 0.0.0
    +17:  * @since 0.1.1 This object is now echoable.
    +18:  * @since 0.1.1 Unstatic every attributes.
    +19:  * @since 0.1.2 Add error reporting.
    +20:  * @subpackage Shopobjects\Information
    +21:  */
    +22: class TermsAndConditionInformation {
     23: 
    -24:     /** @var String The REST path for terms and condition. */
    -25:     const RESTPATH = "legal/terms-and-conditions";
    -26: 
    -27:     /** @var int Timestamp in ms when the next request needs to be done. */
    -28:     private $NEXT_REQUEST_TIMESTAMP = 0;
    -29: 
    -30:     /**
    -31:      * Prints the Information object as a string.
    -32:      *
    -33:      * This function returns the setted values of the Information object.
    -34:      *
    -35:      * @author David Pauli <contact@david-pauli.de>
    -36:      * @since 0.1.1
    -37:      * @return String The Information as a string.
    -38:      */
    -39:     public function __toString() {
    -40: 
    -41:         return "<strong>Name:</strong> " . $this->NAME . "<br/>" .
    -42:                 "<strong>Navigation caption:</strong> " . $this->NAVIGATIONCAPTION . "<br/>" .
    -43:                 "<strong>Description:</strong> " . $this->DESCRIPTION . "<br/>" .
    -44:                 "<strong>Next allowed request time:</strong> " . $this->NEXT_REQUEST_TIMESTAMP . "<br/>";
    -45:     }
    -46: 
    -47: }
    -48: ?>
    +24: use Information, ErrorReporting; +25: +26: /** @var String The REST path for terms and condition. */ +27: const RESTPATH = "legal/terms-and-conditions"; +28: +29: /** @var int Timestamp in ms when the next request needs to be done. */ +30: private $NEXT_REQUEST_TIMESTAMP = 0; +31: +32: } +33: ?> - +