1<?php
2namespace GuzzleHttp\Post;
3
4use GuzzleHttp\Message\AppliesHeadersInterface;
5use GuzzleHttp\Stream\StreamInterface;
6
7/**
8 * Represents a POST body that is sent as either a multipart/form-data stream
9 * or application/x-www-urlencoded stream.
10 */
11interface PostBodyInterface extends StreamInterface, \Countable, AppliesHeadersInterface
12{
13    /**
14     * Set a specific field
15     *
16     * @param string       $name  Name of the field to set
17     * @param string|array $value Value to set
18     */
19    public function setField($name, $value);
20
21    /**
22     * Set the aggregation strategy that will be used to turn multi-valued
23     * fields into a string.
24     *
25     * The aggregation function accepts a deeply nested array of query string
26     * values and returns a flattened associative array of key value pairs.
27     *
28     * @param callable $aggregator
29     */
30    public function setAggregator(callable $aggregator);
31
32    /**
33     * Set to true to force a multipart upload even if there are no files.
34     *
35     * @param bool $force Set to true to force multipart uploads or false to
36     *     remove this flag.
37     */
38    public function forceMultipartUpload($force);
39
40    /**
41     * Replace all existing form fields with an array of fields
42     *
43     * @param array $fields Associative array of fields to set
44     */
45    public function replaceFields(array $fields);
46
47    /**
48     * Get a specific field by name
49     *
50     * @param string $name Name of the POST field to retrieve
51     *
52     * @return string|null
53     */
54    public function getField($name);
55
56    /**
57     * Remove a field by name
58     *
59     * @param string $name Name of the field to remove
60     */
61    public function removeField($name);
62
63    /**
64     * Returns an associative array of names to values or a query string.
65     *
66     * @param bool $asString Set to true to retrieve the fields as a query
67     *     string.
68     *
69     * @return array|string
70     */
71    public function getFields($asString = false);
72
73    /**
74     * Returns true if a field is set
75     *
76     * @param string $name Name of the field to set
77     *
78     * @return bool
79     */
80    public function hasField($name);
81
82    /**
83     * Get all of the files
84     *
85     * @return array Returns an array of PostFileInterface objects
86     */
87    public function getFiles();
88
89    /**
90     * Get a POST file by name.
91     *
92     * @param string $name Name of the POST file to retrieve
93     *
94     * @return PostFileInterface|null
95     */
96    public function getFile($name);
97
98    /**
99     * Add a file to the POST
100     *
101     * @param PostFileInterface $file File to add
102     */
103    public function addFile(PostFileInterface $file);
104
105    /**
106     * Remove all files from the collection
107     */
108    public function clearFiles();
109}
110